NJsonSchema
NJsonSchema copied to clipboard
Ability to ignore case related errors.
I would like the ability to ignore errors regarding casing.
The problem is validating json with improper casing ie {Name:"Derek"} vs {name:"Derek"} generates the error "NoAdditionalPropertiesAllowed". This is the same as the error I would get with the validation against {name1:"Derek"}. What are the thoughts of adding a ValidationErrorKind.PropertyMismatch that makes it easier to distinguish this.
I'm happy to hope in and code this, just want to make sure its inline with the goals of this open source project first.
Thanks!
I don't think its a good idea to introduce PropertyMismatch because you cannot know whether its PropertyMismatch or NoAdditionalPropertiesAllowed...
My suggestion is to add a second parameter to
public JsonSchemaValidator(JsonSchema4 schema)
this(schema, new JsonSchemaValidatorSettings())
{
}
public JsonSchemaValidator(JsonSchema4 schema, JsonSchemaValidatorSettings settings)
{
_schema = schema.ActualSchema;
_settings = settings;
}
And
public class JsonSchemaValidatorSettings
{
public bool IgnorePropertyNameCase { get; set; }
}
And handle this in the validator...
@RicoSuter I'm interested in knowing if there is any timelines on when this will be added to the main branch. I currently have a requirement where I maintain a json schema in the API and client requests will be validated against this schema. Now, clients json could have different casing from the schema and NoAdditionalPropertiesAllowed
doesn't look appropriate. 👍 for this library