RicoSuter/NJsonSchema
View on GitHubminlength is impacted by required attribute in json schema
Open
#768 opened on Aug 31, 2018
help wantedtype: enhancement
Repository metrics
- Stars
- (1,578 stars)
- PR merge metrics
- (Avg merge 39d 6h) (1 merged PR in 30d)
Description
I used below schema to generate C# code using CSharpGenerator. But there is no validation for the length if the field marked as required. The validation ( [System.ComponentModel.DataAnnotations.StringLength(int.MaxValue, MinimumLength = 1)]) is correctly generated if the field is not marked as required.
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "files": { "type": "string", "minlength": 1 } }, "required": [ "files" ] }
Is this intentional? I am using version: 9.10.67 on nuget.