-
Notifications
You must be signed in to change notification settings - Fork 21
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
Use an ErrorHandler to detect multiple errors #20
Comments
By way of explanation (sorry for the essay): The documentation around Validator.validate is a bit dodgy, but the only obligation on a Validator is to throw fatal exceptions. The normal method for Validator.validate to report errors is through an ErrorHandler, and the javadoc on ErrorHandler makes it clear that a validation error is not a fatal exception. What Validator.validate is meant to do if no ErrorHandler is set isn't really contemplated by the javadoc. While its fair to say that it should probably treat validation errors as fatal errors in this circumstance, its certainly not obligated to. |
Fixed in pull request #18 |
…del processing instruction)
…rrorHandler to detect most validation failures reliably. To simplify this, existing error handling was refactored to use the more general ErrorHandler added here in all situations.
When using Validator.validate, most validation errors will be ignored. The only reliable way to capture validation errors is to use an error handler, as Validator.validate only throws fatal errors (validation errors are not fatal - see javadoc for ErrorHandler) Solution applied refactors existing error handling approach to always use an ErrorHandler to capture errors. As a bonus, you should get log messages showing multiple failures, rather than just the first.
When using Validator.validate, most validation errors will be ignored. The only reliable way to capture validation errors is to use an error handler, as Validator.validate only throws fatal errors (validation errors are not fatal - see javadoc for ErrorHandler) Solution applied refactors existing error handling approach to always use an ErrorHandler to capture errors. As a bonus, you should get log messages showing multiple failures, rather than just the first.
I misread the spec, and the handling of null ErrorHandler is actually specified in the standard. |
When using a Schema, and ultimately using one of the Validator.validate methods, the plugin does not properly detect validation failures. When using Validator.validate, the plugin should set an ErrorHandler on the Validator and collect errors that way (and report them at the end). This has the added advantage of collecting and reporting multiple validation problems.
The text was updated successfully, but these errors were encountered: