Skip to content

Add cause exception to ValidationException - so that error handlers can get the validator implementation specific original constraint violations #245

Closed
@rbygrave

Description

@rbygrave

I've just hooked up the validation to avaje-nima and looking at the difference between the avaje-validation ConstraintViolationException and avaje-http ValidationException.

When mapping from ConstraintViolationException -> avaje-http ValidationException we can lose details that ConstraintViolationException has and to me that could be problematic (and problematic for other validators that someone might wish to use).

I'm pondering if we should effectively remove / deprecate / not use the avaje-http ValidationException and instead allow the ConstraintViolationException to be thrown and then the error handler has full control over how the ConstraintViolationException is handled.

That is, the API requirement for avaje-http validate() becomes that it throws some RuntimeException (a ConstraintViolationException) and it's up to the http routing to have a error handler registered to handle that specific exception.

Another alternative is for ValidationException to have a cause which in the avaje-validation case is the ConstraintViolationException.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions