[hibernate-commits] [hibernate/hibernate-validator] d8ecc2: HV-951 Make expression variables added via context...

GitHub noreply at github.com
Fri Jan 9 11:00:31 EST 2015


  Branch: refs/heads/master
  Home:   https://github.com/hibernate/hibernate-validator
  Commit: d8ecc202591d038e78742d3b1e4550fa87eadb67
      https://github.com/hibernate/hibernate-validator/commit/d8ecc202591d038e78742d3b1e4550fa87eadb67
  Author: Nicolas FRANÇOIS <nicolas.francois at opentrust.com>
  Date:   2015-01-09 (Fri, 09 Jan 2015)

  Changed paths:
    M engine/src/main/java/org/hibernate/validator/internal/engine/ConstraintViolationImpl.java
    M engine/src/main/java/org/hibernate/validator/internal/engine/ValidationContext.java
    M engine/src/test/java/org/hibernate/validator/test/internal/engine/constraintvalidation/HibernateConstraintValidatorContextTest.java

  Log Message:
  -----------
  HV-951 Make expression variables added via context.addExpressionVariable(String, Object) accessible from the ConstraintViolation object.

This commit adds a new getExpressionVariables() getter to ConstraintViolationImpl and minor changes to the internals:
 * add an argument to ConstraintViolationImpl private constructor
 * overload ConstraintViolationImpl.forBeanValidation & co. to handle the new constructor argument, and mark previous, overloaded ones as @Deprecated
 * adjust ValidationContext.createConstraintViolation(ValueContext<?, ?>, ConstraintViolationCreationContext, ConstraintDescriptor<?>) to pass expressionVariables as un unmodifiable Map to the overloaded builders
 * unit test :p

Useful for:
 * Single page web applications, when all i18n/l10n/interpolation stuff is handled client side in JS.
 * Web services, where we want to expose constraint violations in a parsable way. WS client may present the error to users, depending on their prefered locale, and do the interpolation itself.




More information about the hibernate-commits mailing list