validationgrailscommandconstraintsgrails-2.4

Grails inList Constraint get values of inList map in error message


I am using inList constraint to validate list of values. And I am not using directly command/domain class to show error message

ex:

name inList: ["Joe", "Fred", "Bob"]

if name is not from the list error message is shown as

Property [{0}] of class [{1}] with value [{2}] is not contained within the list [{3}]

Instead i want to show a proper message having values as Property of name of class MyClass with value XYZ is not contained within the list Joe, Fred, Bob.

Whereas MyClass , XYZ and List values must be coming from cmd object that I use to validate.

Please help on how to show this message.


Solution

  • I got the solution for it.

    I can get the rejected value from cmd.errors.getRejectedValue() and I can get list of values from cmd.constraints.name.inList