I am using spring-data-rest for a project and I am looking at introducing validation.
I can add my validator manually by expanding the RepositoryRestConfigurerAdapter and overriding configureValidatingRepositoryEventListener to add my validator.
Verification is done, however I get a response of 500, not the expected 400.
The top of the call table is as follows:
threw exception [Request processing failed; nested exception is org.springframework.data.rest.core.RepositoryConstraintViolationException: Validation failed] with root cause org.springframework.data.rest.core.RepositoryConstraintViolationException: Validation failed at org.springframework.data.rest.core.event.ValidatingRepositoryEventListener.validate(ValidatingRepositoryEventListener.java:179) ~[spring-data-rest-core-2.5.2.RELEASE.jar:na] at org.springframework.data.rest.core.event.ValidatingRepositoryEventListener.onBeforeCreate(ValidatingRepositoryEventListener.java:96) ~[spring-data-rest-core-2.5.2.RELEASE.jar:na]
The RepositoryRestExceptionHandler handleRepositoryConstraintViolationException method does not seem to throw an exception for any reason.
I have seen other types of restrictions, for example. MongoDB's unique index constraints are successfully converted to 400.
Any thoughts on how to resolve this will be appreciated.
source share