Namespace: Json.Schema.Generation.DataAnnotations
Inheritance: StringLengthAttributeHandler 🡒 object
Implemented interfaces:
- IAttributeHandler<StringLengthAttribute>
- IAttributeHandler
Adds a maxLength and an optional minLength keyword.
Remarks
minLength will be not be added if the value is less than or equal to zero.
Methods
AddConstraints(SchemaGenerationContextBase context, Attribute attribute)
Processes the type and any attributes (present on the context), and adds intents to the context.
Declaration
1
public void AddConstraints(SchemaGenerationContextBase context, Attribute attribute)
| Parameter | Type | Description |
|---|---|---|
| context | SchemaGenerationContextBase | The generation context. |
| attribute | Attribute | The attribute. |
Remarks
A common pattern is to implement Json.Schema.Generation.IAttributeHandler on the attribute itself. In this case, the
Apply(JsonSchemaBuilder builder, int maximumLength, int minimumLength)
Applies constraints for source generation.
Declaration
1
public static JsonSchemaBuilder Apply(JsonSchemaBuilder builder, int maximumLength, int minimumLength)
| Parameter | Type | Description |
|---|---|---|
| builder | JsonSchemaBuilder | The schema builder. |
| maximumLength | int | The maximum length. |
| minimumLength | int | The minimum length. |
Returns
The builder for chaining.