buildConstraintViolationWithTemplate('some message') does not work.
context.disableDefaultConstraintViolation();
context.buildConstraintViolationWithTemplate("{customConstraint.duplicateName}")
.addConstraintViolation();
the above code will output whatever is defined in the default message.
context.disableDefaultConstraintViolation();
context.buildConstraintViolationWithTemplate("{customConstraint.duplicateName}")
.addPropertyNode(null).inIterable().atKey(field)
.addPropertyNode("name")
.addConstraintViolation();
the above code will ignore the message and default message and will out put the code with the fiull path and the name of the constraint prepended.
I wrote up a stackoverflow question here with more detail :
http://stackoverflow.com/questions/29519433/constraintvalidatorcontext-not-sending-messages
|