eclipsesource/play-json-schema-validator

Invalid schema type should not throw MatchError exception

Closed this issue · 2 comments

If schema type is invalid, e.g.

"someProp": {"type": "sting"}

the schema parsing should not throw MatchError exception. Instead the parsing should return with an error result. The lines of code where the exception originates from, are internal/serialization/JSONSchemaReads.scala:15.

Thanks for the report. While I agree, of course, that the validator should not fail with a MatchError, I'm unsure about whether parsing should return an error. Instead, I think, someProp should be ignored and parsing should succeed, but with an empty schema.

Thanks for the quick response!

Now that I think about it, I agree that the parsing should continue and succeed. But the error in the schema should still be reported to help the user to fix it. I believe your fix does just this, so good job :)