Merge pull request #599 from jamesagnew/add_hook_for_post_processing_validation_result_on_failure

Added a validation post-processing hook.
This commit is contained in:
James Agnew 2017-03-17 20:40:28 -04:00 committed by GitHub
commit 1f380ad205
2 changed files with 11 additions and 0 deletions

View File

@ -267,6 +267,11 @@ abstract class BaseValidatingInterceptor<T> extends InterceptorAdapter {
*/
protected void postProcessResult(RequestDetails theRequestDetails, ValidationResult theValidationResult) { }
/**
* Hook for subclasses on failure (e.g. add a response header to an incoming resource upon rejection).
*/
protected void postProcessResultOnFailure(RequestDetails theRequestDetails, ValidationResult theValidationResult) { }
/**
* Note: May return null
*/
@ -314,6 +319,7 @@ abstract class BaseValidatingInterceptor<T> extends InterceptorAdapter {
if (myFailOnSeverity != null) {
for (SingleValidationMessage next : validationResult.getMessages()) {
if (next.getSeverity().ordinal() >= myFailOnSeverity) {
postProcessResultOnFailure(theRequestDetails, validationResult);
fail(theRequestDetails, validationResult);
return validationResult;
}

View File

@ -202,6 +202,11 @@
the JPA database, improving performance of this operation. Thanks to
Joel Schneider for the pull request and analysis!
</action>
<action type="add">
A new post-processing hook for subclasses of BaseValidatingInterceptor is now
available. The hook exposes the request details on validation failure prior to throwing an
UnprocessableEntityException.
</action>
</release>
<release version="2.2" date="2016-12-20">
<action type="add">