|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.xwork2.validator.validators.ValidatorSupport
com.opensymphony.xwork2.validator.validators.FieldValidatorSupport
com.opensymphony.xwork2.validator.validators.RegexFieldValidator
public class RegexFieldValidator
Validates a string field using a regular expression.
true
.true
.<validators> <!-- Plain Validator Syntax --> <validator type="regex"> <param name="fieldName">myStrangePostcode</param> <param name="regex"><![CDATA[([aAbBcCdD][123][eEfFgG][456])]]></param> </validator> <!-- Field Validator Syntax --> <field name="myStrangePostcode"> <field-validator type="regex"> <param name="regex"><![CDATA[([aAbBcCdD][123][eEfFgG][456])]]></param> </field-validator> </field> <!-- Field Validator Syntax with expressions --> <field name="myStrangePostcode"> <field-validator type="regex"> <param name="regexExpression">${regexValue}</param> <!-- will be evaluated as: String getRegexValue() --> <param name="caseSensitiveExpression">${caseSensitiveValue}</param> <!-- will be evaluated as: boolean getCaseSensitiveValue() --> <param name="trimExpression">${trimValue}</param> <!-- will be evaluated as: boolean getTrimValue() --> </field-validator> </field> </validators>
Field Summary |
---|
Fields inherited from class com.opensymphony.xwork2.validator.validators.ValidatorSupport |
---|
defaultMessage, log, messageKey, stack |
Constructor Summary | |
---|---|
RegexFieldValidator()
|
Method Summary | |
---|---|
String |
getRegex()
|
boolean |
isCaseSensitive()
|
boolean |
isTrimed()
|
void |
setCaseSensitive(Boolean caseSensitive)
Sets whether the expression should be matched against in a case-sensitive way. |
void |
setCaseSensitiveExpression(String caseSensitiveExpression)
Allows specify caseSensitive param as an OGNL expression |
void |
setRegex(String regex)
Sets the regular expression to be matched |
void |
setRegexExpression(String regexExpression)
Sets the regular expression as an OGNL expression to be matched |
void |
setTrim(Boolean trim)
Sets whether the expression should be trimed before matching. |
void |
setTrimExpression(String trimExpression)
Allows specify trim param as an OGNL expression |
void |
validate(Object object)
The validation implementation must guarantee that setValidatorContext will be called with a non-null ValidatorContext before validate is called. |
Methods inherited from class com.opensymphony.xwork2.validator.validators.FieldValidatorSupport |
---|
getFieldName, getValidatorType, setFieldName, setValidatorType |
Methods inherited from class com.opensymphony.xwork2.validator.validators.ValidatorSupport |
---|
addActionError, addFieldError, getDefaultMessage, getFieldValue, getMessage, getMessageKey, getMessageParameters, getValidatorContext, isShortCircuit, parse, setDefaultMessage, setMessageKey, setMessageParameters, setShortCircuit, setValidatorContext, setValueStack |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.opensymphony.xwork2.validator.Validator |
---|
getDefaultMessage, getMessage, getMessageKey, getMessageParameters, getValidatorContext, setDefaultMessage, setMessageKey, setMessageParameters, setValidatorContext, setValueStack |
Constructor Detail |
---|
public RegexFieldValidator()
Method Detail |
---|
public void validate(Object object) throws ValidationException
Validator
object
- the object to be validated.
ValidationException
- is thrown if there is validation error(s).public String getRegex()
public void setRegex(String regex)
public void setRegexExpression(String regexExpression)
public boolean isCaseSensitive()
true
.public void setCaseSensitive(Boolean caseSensitive)
true
.
public void setCaseSensitiveExpression(String caseSensitiveExpression)
public boolean isTrimed()
true
.public void setTrim(Boolean trim)
true
.
public void setTrimExpression(String trimExpression)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |