|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springmodules.validation.bean.RuleBasedValidator
public class RuleBasedValidator
A Validator
implementation which uses ValidationRule
's to define its
validation execution. There are two types of validation rules this validator accepts:
Errors
object (i.e. Errors.reject(String)
).
Errors
object under the context of those properties
(i.e. Errors.rejectValue(String, String)
).
Constructor Summary | |
---|---|
RuleBasedValidator()
Contrusts a new RuleBasedValidator for the given type. |
Method Summary | |
---|---|
void |
addGlobalRule(Condition condition,
String errorCode)
Adds a new global validation rule to this validator. |
void |
addGlobalRule(Condition condition,
String errorCode,
Object[] args)
Adds a new global validation rule to this validator. |
void |
addGlobalRule(Condition condition,
String errorCode,
String message)
Adds a new global validation rule to this validator. |
void |
addGlobalRule(Condition condition,
String errorCode,
String message,
Object[] args)
Adds a new global validation rule to this validator. |
void |
addGlobalRule(ValidationRule globalRule)
Adds the given validation rule as a global rule to this validator. |
void |
addPropertyGlobalRule(String propertyName,
ValidationRule globalRule)
Adds a property rule for the given property. |
void |
addPropertyRule(String propertyName,
Condition fieldValueCondition,
String errorCode)
Adds the given property rule to this validator. |
void |
addPropertyRule(String propertyName,
Condition fieldValueCondition,
String errorCode,
Object[] args)
Adds the given property rule to this validator. |
void |
addPropertyRule(String propertyName,
Condition fieldValueCondition,
String errorCode,
String message,
Object[] args)
Adds the given property rule to this validator. |
void |
addPropertyRule(String propertyName,
ValidationRule propertyRule)
Adds the given property rule for the given property. |
void |
setExtraGlobalVadlidationRules(ValidationRule[] globalRules)
Sets extra global validation rules for this validator. |
void |
setExtraPropertyValidationRules(Map rulesByProperty)
Sets extra property validation rules for this validator. |
boolean |
supports(Class clazz)
This validator supports all classes. |
void |
validate(Object obj,
Errors errors)
Validates the given object and registers all validation errors with the given errors object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RuleBasedValidator()
Method Detail |
---|
public boolean supports(Class clazz)
supports
in interface Validator
Validator.supports(Class)
public void validate(Object obj, Errors errors)
validate
in interface Validator
Validator.validate(Object, org.springframework.validation.Errors)
public void setExtraGlobalVadlidationRules(ValidationRule[] globalRules)
globalRules
- The extra global validation rules to be added to this validator.public void setExtraPropertyValidationRules(Map rulesByProperty)
rulesByProperty
- The extra property validation rules for this validator. The map should hold the property
names as keys and ValidationRule
instances as values.public void addPropertyRule(String propertyName, Condition fieldValueCondition, String errorCode)
Errors
object under the context of the associated property. Note that the associated property
may be a nested property - in that case, the nested property value will be resolved and the condition will be
applied on the this value.
propertyName
- The name of the property the added rule is associated with.fieldValueCondition
- The condition of the rule.errorCode
- The error code of the rule.public void addPropertyRule(String propertyName, Condition fieldValueCondition, String errorCode, Object[] args)
propertyName
- The name of the property the added rule is associated with.fieldValueCondition
- The condition of the rule.errorCode
- The error code of the rule.args
- The arguments of the error code of the rule.addPropertyRule(String, org.springmodules.validation.util.condition.Condition, String, Object[])
public void addPropertyRule(String propertyName, Condition fieldValueCondition, String errorCode, String message, Object[] args)
propertyName
- The name of the property the added rule is associated with.fieldValueCondition
- The condition of the rule.errorCode
- The error code of the rule.message
- The default error message of the rule.args
- The arguments of the error code of the rule.addPropertyRule(String, org.springmodules.validation.util.condition.Condition, String, Object[])
public void addPropertyRule(String propertyName, ValidationRule propertyRule)
propertyName
- The name of the property associated with the added rule.propertyRule
- The rule that should be applied on the value of the given property.addPropertyRule(String, org.springmodules.validation.util.condition.Condition, String)
public void addPropertyGlobalRule(String propertyName, ValidationRule globalRule)
propertyName
- The name of the property to associated with the added rule.globalRule
- The global rule to be added.public void addGlobalRule(Condition condition, String errorCode)
Errors
object globaly
(see Errors.reject(String)
).
condition
- The condition of the added rule.errorCode
- The error code of the added rule.public void addGlobalRule(Condition condition, String errorCode, Object[] args)
condition
- The condition of the added rule.errorCode
- The error code of the added rule.args
- The arguments for the error of the added rule.addGlobalRule(org.springmodules.validation.util.condition.Condition, String)
public void addGlobalRule(Condition condition, String errorCode, String message, Object[] args)
condition
- The condition of the added rule.errorCode
- The error code of the added rule.message
- The error message of the added rule.args
- The arguments for the error of the added rule.addGlobalRule(org.springmodules.validation.util.condition.Condition, String)
public void addGlobalRule(Condition condition, String errorCode, String message)
condition
- The condition of the added rule.errorCode
- The error code of the added rule.message
- The default error message of the added rule.addGlobalRule(org.springmodules.validation.util.condition.Condition, String)
public void addGlobalRule(ValidationRule globalRule)
globalRule
- The global rule to be added to this validator.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |