Class ConstraintViolation

  • All Implemented Interfaces:
    Serializable, ValidationViolation

    public class ConstraintViolation
    extends Object
    implements ValidationViolation
    A constraint violation description. Use getMessage(Locale) to get the constraint violation description.

    You could customize constraint violation message using the following rules :

    • Use "label.schema.constraint.violation" key in "messages" bundle to customize default message
    • Append the constraint name to the previous key to customize the generic message to some constraint
    • Append the schema and the field name to the previous key to customize the message for a specific constraint applied to some specific schema field.

    For each messages, you can use parameters in the message :
    • The invalid value : {0}
    • The schema name : {1}
    • The field name : {2}
    • The constraint name : {3}
    • The first constraint parameter (if exists) : {4}
    • The second constraint parameter (if exists) : {5}
    • ...

    Examples :

    • label.schema.constraint.violation=Value '{0}' for field '{1}.{2}' does not respect constraint '{3}'
    • label.schema.constraint.violation.PatternConstraint='{1}.{2}' value ({0}) should match the following format : '{4}'
    • label.schema.constraint.violation.PatternConstraint.myuserschema.firstname ='The firstname should not be empty'
    Since:
    7.1
    See Also:
    Serialized Form