You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we add a patternProperties validation to a json schema, calling schema.Validate() validates only additional properties.
I don't know if this behavior is intended, but I believe this unit test should have passed:
[Fact]
public void When_property_value_doesnt_match_pattern_then_validation_fails()
{
//// Arrange
var schema = new JsonSchema();
schema.Type = JsonObjectType.Object;
schema.Properties.Add("capitallettersonly", new JsonSchemaProperty() { Type = JsonObjectType.String });
schema.AllowAdditionalProperties = false;
schema.PatternProperties.Add("^[a-z]+$", new JsonSchemaProperty() { Pattern = "^[A-Z]+$" });
var token = new JObject();
token.Add("capitallettersonly", new JValue("lowercase"));
//// Act
var errors = schema.Validate(token);
//// Assert
Assert.Single(errors);
Assert.Equal(ValidationErrorKind.PatternMismatch, errors.First().Kind);
}
If we look at JsonSchemaValidator.cs, we will notice that only additionalProperties are passed as argument.
The text was updated successfully, but these errors were encountered:
When we add a patternProperties validation to a json schema, calling
schema.Validate()
validates only additional properties.I don't know if this behavior is intended, but I believe this unit test should have passed:
If we look at JsonSchemaValidator.cs, we will notice that only additionalProperties are passed as argument.
The text was updated successfully, but these errors were encountered: