Interface Constraint
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
AbstractConstraint
,DateIntervalConstraint
,EnumConstraint
,LengthConstraint
,NotNullConstraint
,NumericIntervalConstraint
,ObjectResolverConstraint
,PatternConstraint
,TypeConstraint
A constraint object defines a constraint on a custom type. Method
getDescription()
allows anyone to
dynamically redefine this constraint in another language (for example in javascript to make client-side validation).- Since:
- 7.1
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
Represent the description of a constraint. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionProvides a description of a constraint.getErrorMessage
(Object invalidValue, Locale locale) Provides an error message to display when some invalid value does not match existing entity.Provides the message key.boolean
Validates the given object against this constraint.
-
Field Details
-
MESSAGES_BUNDLE
- See Also:
-
MESSAGES_DEFAULT_LANG
-
MESSAGES_KEY
- See Also:
-
-
Method Details
-
validate
Validates the given object against this constraint.If some object is null. Constraint should return true while validating unless the constraint deals with nullable state.
- Parameters:
object
- the object to validate- Returns:
- true if the object was successfully validated, false otherwise
-
getErrorMessage
Provides an error message to display when some invalid value does not match existing entity.- Parameters:
invalidValue
- The invalid value that don't match any entity.locale
- The language in which the message should be generated.- Returns:
- A message in the specified language or
- Since:
- 7.1
-
getMessageKey
String getMessageKey()Provides the message key.- Returns:
- The message key
- Since:
- 11.1
-
getDescription
Constraint.Description getDescription()Provides a description of a constraint. For example, a constraint which control String format could returnname=PatternMatchingConstraint | parameters= "pattern":"[0-9]+"
- Returns:
- The constraint description.
- Since:
- 7.1
-