vertx-json-schema icon indicating copy to clipboard operation
vertx-json-schema copied to clipboard

Add Output Error Types when Schema validation fails

Open CheesyBoy123 opened this issue 1 year ago • 0 comments

Describe the feature

When doing schema validation, it is useful to know what went wrong in a very easy way. For example if you have the schema:

field:
  type: string
  required: true

But you do not pass this field, you would see that the validation has failed. It would be extremely hard to know why the validation failed. Was it because the type was invalid or the field was missing all together? Currently, if you wanted to know you would have to parse the error messages:

Instance does not have required property \"" + key + "\"" <--- Required but missing "Instance type " + instanceType + " is invalid. Expected " + schema.get("type") <--- The type is invalid

I think adding a new Enum valid to describe the error type would be extremely helpful.

Use cases

Since the program knows why the validation failed, it can gracefully catch the exception and pass that on to the end user in a cleaner fashion.

Contribution

Who should implement this feature ? are you volunteering for implementing this feature or do you know that is able and willing implement this feature ?

CheesyBoy123 avatar May 19 '24 21:05 CheesyBoy123