Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The throw statement throws an exception, displaying errors for fields that do not meet the specified validation rules. #122

Closed
difflib opened this issue Nov 30, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@difflib
Copy link

difflib commented Nov 30, 2023

Describe the feature

When application throws a JsonSchemaValidationException exception,no message for more detail.
I would like to throw validation error so that the modal will show the form field that has the error.

Use cases

Source:

val repository = SchemaRepository.create(JsonSchemaOptions().setDraft(Draft.DRAFT202012).setBaseUri("app://"))
repository.dereference("test.json", JsonSchema.of(jsonObject))            
val validator=repository.validator("test.json").validate(json).checkValidity()
} catch (th: Throwable) {
      th.printStackTrace()
}

Result:

15:11:05.984 DEBUG [vert.x-eventloop-thread-1] io.netty.handler.logging.LoggingHandler [id: 0x2a560fc3, L:/127.0.0.1:9091 - R:/127.0.0.1:4136] READ COMPLETE
io.vertx.json.schema.JsonSchemaValidationException: JsonSchema Validation error

Just olny JsonSchema Validation error,which field no pass?

@difflib difflib added the enhancement New feature or request label Nov 30, 2023
@pk-work
Copy link
Contributor

pk-work commented May 31, 2024

When you validate a schema your result is an OutputUnit. This OutputUnit shows you why the validation failed.

Example:

#/items: Items did not match schema
#/items/$ref: A subschema had errors
#/items/$ref/oneOf: Instance does not match exactly one subschema (0 matches)
#/items/$ref/oneOf/0/$ref: A subschema had errors
#/items/$ref/oneOf/0/$ref/allOf: Instance does not match every subschema
#/items/$ref/oneOf/0/$ref/allOf/1/properties: Property "value" does not match schema
#/items/$ref/oneOf/0/$ref/allOf/1/properties/value/type: Instance type string is invalid. Expected integer
#/items/$ref/oneOf/1/$ref: A subschema had errors
#/items/$ref/oneOf/1/$ref/allOf: Instance does not match every subschema
#/items/$ref/oneOf/1/$ref/allOf/1/properties: Property "modelType" does not match schema
#/items/$ref/oneOf/1/$ref/allOf/1/properties/modelType/pattern: String does not match pattern
#/items/$ref/oneOf/2/$ref: A subschema had errors
#/items/$ref/oneOf/2/$ref/allOf: Instance does not match every subschema
#/items/$ref/oneOf/2/$ref/allOf/1/properties: Property "value" does not match schema
#/items/$ref/oneOf/2/$ref/allOf/1/properties/value/type: Instance type string is invalid. Expected array
#/items/$ref/oneOf/2/$ref/allOf/1/properties: Property "modelType" does not match schema
#/items/$ref/oneOf/2/$ref/allOf/1/properties/modelType/pattern: String does not match pattern

@pk-work pk-work closed this as completed May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants