Class ConstraintViolation
- java.lang.Object
-
- org.nuxeo.ecm.core.api.validation.ConstraintViolation
-
- All Implemented Interfaces:
Serializable
,ValidationViolation
public class ConstraintViolation extends Object implements ValidationViolation
A constraint violation description. UsegetMessage(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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConstraintViolation.PathNode
Allows to locates some constraint violation in a document.
-
Constructor Summary
Constructors Constructor Description ConstraintViolation(Schema schema, List<ConstraintViolation.PathNode> fieldPath, Constraint constraint, Object invalidValue)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Constraint
getConstraint()
Object
getInvalidValue()
String
getMessage(Locale locale)
String
getMessageKey()
List<ConstraintViolation.PathNode>
getPath()
String
getPathAsString()
Schema
getSchema()
String
toString()
-
-
-
Constructor Detail
-
ConstraintViolation
public ConstraintViolation(Schema schema, List<ConstraintViolation.PathNode> fieldPath, Constraint constraint, Object invalidValue)
-
-
Method Detail
-
getSchema
public Schema getSchema()
-
getPath
public List<ConstraintViolation.PathNode> getPath()
-
getPathAsString
public String getPathAsString()
-
getConstraint
public Constraint getConstraint()
-
getInvalidValue
public Object getInvalidValue()
-
getMessage
public String getMessage(Locale locale)
- Specified by:
getMessage
in interfaceValidationViolation
- Returns:
- The message if it's found in message bundles, a generic message otherwise.
- Since:
- 7.1
-
getMessageKey
public String getMessageKey()
- Specified by:
getMessageKey
in interfaceValidationViolation
-
-