|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Check
interface for classes that can check/validate if a constraint is satisfied
Method Summary | |
---|---|
ConstraintTarget[] |
getAppliesTo()
In case the constraint is declared for an array, collection or map this controls how the constraint is applied to it and it's child objects. |
OValContext |
getContext()
|
String |
getErrorCode()
|
String |
getMessage()
gets the default message that is displayed if a corresponding message key is not found in the messages properties file default processed place holders are: {context} => specifies which getter, method parameter or field was validated {invalidValue} => string representation of the validated value |
Map<String,? extends Serializable> |
getMessageVariables()
values that are used to fill place holders when rendering the error message. |
String[] |
getProfiles()
|
int |
getSeverity()
|
String |
getTarget()
An expression to specify where in the object graph relative from this object the expression should be applied. |
String |
getWhen()
Formula returning true if this constraint shall be evaluated and
false if it shall be ignored for the current validation. |
boolean |
isActive(Object validatedObject,
Object valueToValidate,
Validator validator)
|
boolean |
isSatisfied(Object validatedObject,
Object valueToValidate,
OValContext context,
Validator validator)
This method implements the validation logic |
void |
setAppliesTo(ConstraintTarget... target)
|
void |
setContext(OValContext context)
|
void |
setErrorCode(String errorCode)
|
void |
setMessage(String message)
sets the default message that is displayed if a corresponding message key is not found in the messages properties file default processed place holders are: {context} => specifies which getter, method parameter or field was validated {invalidValue} => string representation of the validated value |
void |
setProfiles(String... profiles)
|
void |
setSeverity(int severity)
|
void |
setTarget(String target)
Sets an expression to specify where in the object graph relative from this object the expression should be applied. |
void |
setWhen(String when)
Sets the formula returning true if this constraint shall be evaluated and
false if it shall be ignored for the current validation. |
Method Detail |
---|
ConstraintTarget[] getAppliesTo()
In case the constraint is declared for an array, collection or map this controls how the constraint is applied to it and it's child objects.
Default: ConstraintTarget.CONTAINER
Note: This setting is ignored for object types other than array, map and collection.
OValContext getContext()
ClassContext
,
FieldContext
,
MethodEntryContext
,
MethodExitContext
,
MethodParameterContext
,
MethodReturnValueContext
String getErrorCode()
String getMessage()
Map<String,? extends Serializable> getMessageVariables()
String[] getProfiles()
int getSeverity()
String getTarget()
Examples:
owner
owner
's property id
String getWhen()
true
if this constraint shall be evaluated and
false
if it shall be ignored for the current validation.
Important: The formula must be prefixed with the name of the scripting language that is used.
E.g. groovy:_this.amount > 10
Available context variables are:
_this -> the validated bean
_value -> the value to validate (e.g. the field value, parameter value, method return value,
or the validated bean for object level constraints)
boolean isActive(Object validatedObject, Object valueToValidate, Validator validator)
validatedObject
- the object/bean to validate the value against, for static fields or methods this is the classvalueToValidate
- the value to validate, may be null when validating pre conditions for static methodsvalidator
- the calling validator
true
if this check is active and must be satisfiedboolean isSatisfied(Object validatedObject, Object valueToValidate, OValContext context, Validator validator) throws OValException
validatedObject
- the object/bean to validate the value against, for static fields or methods this is the classvalueToValidate
- the value to validate, may be null when validating pre conditions for static methodscontext
- the validation context (e.g. a field, a constructor parameter or a method parameter)validator
- the calling validator
OValException
void setAppliesTo(ConstraintTarget... target)
target
- the constraint target to setvoid setContext(OValContext context)
context
- the context to setvoid setErrorCode(String errorCode)
errorCode
- the error code to setvoid setMessage(String message)
void setProfiles(String... profiles)
profiles
- the profiles to setvoid setSeverity(int severity)
severity
- the severity to setvoid setTarget(String target)
Examples:
owner
owner
's property id
void setWhen(String when)
true
if this constraint shall be evaluated and
false
if it shall be ignored for the current validation.
Important: The formula must be prefixed with the name of the scripting language that is used.
E.g. groovy:_this.amount > 10
Available context variables are:
_this -> the validated bean
_value -> the value to validate (e.g. the field value, parameter value, method return value,
or the validated bean for object level constraints)
when
- formula calculating if this check is active
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |