Dp
Ultimate problem:
It did not provide an easy way to customize error messages for specific validation errors. This limitation made it difficult for developers to deliver user-friendly error messages when validating JSON against a schema.
How it was fixed:
added a customMessage property to allow developers to specify custom error messages for specific validation errors in the schema.
Testing suggestions:
Potential areas of regression:
Hello @AvoMandjian and thanks for your PR! While I like the idea of allowing users to customize their error messages, we've also tried to adhere pretty strictly to features described in the JSON Schema specification. Your PR would add a custom keyword that is not listed in the spec, and therefore I don't believe we can accept it as-is. A couple options for you going forward.
- While keeping them generic for all schemas, we'd be happy to accept contributions that improve the error messages for validation on standard keywords
- You could check out custom vocabularies, part of the JSON Schema standard, that would allow you to extend your schema with new keywords, while keeping those modifications specific to your codebase(s). a. Example: https://github.com/Workiva/json_schema/blob/master/example/custom_vocabulary/custom_date_range.dart b. Reference: https://json-schema.org/learn/glossary#vocabulary
- You could add an "unknown keyword" in your schema (which will be ignored if not defined in the standard vocabulary), and use a wrapping class to add your own custom validation error classes, translating or ignoring the built-in errors and adding your own.