public class RegexFieldValidator extends FieldValidatorSupport
true.true.You can mix normal params with expression aware params but thus was not tested
Do not use ${regexExpression}, ${caseSensitiveExpression} and ${trimExpression} as an expression as this will turn into infinitive loop!
 
 <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>
 
 currentValue, fieldName, typedefaultMessage, EMPTY_STRING, messageKey, stack, textProviderFactory| Constructor and Description | 
|---|
RegexFieldValidator()  | 
| Modifier and Type | Method and Description | 
|---|---|
String | 
getRegex()  | 
boolean | 
isCaseSensitive()  | 
boolean | 
isTrimed()  | 
void | 
setCaseSensitive(Boolean caseSensitive)  | 
void | 
setCaseSensitiveExpression(String caseSensitiveExpression)  | 
void | 
setRegex(String regex)  | 
void | 
setRegexExpression(String regexExpression)  | 
void | 
setTrim(Boolean trim)  | 
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. 
 | 
protected void | 
validateFieldValue(Object object,
                  String value,
                  String regexToUse)  | 
getCurrentValue, getFieldName, getValidatorType, setFieldName, setValidatorTypeaddActionError, addFieldError, getDefaultMessage, getFieldValue, getMessage, getMessageKey, getMessageParameters, getValidatorContext, isShortCircuit, parse, setDefaultMessage, setMessageKey, setMessageParameters, setShortCircuit, setTextProviderFactory, setValidatorContext, setValueStackclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetDefaultMessage, getMessage, getMessageKey, getMessageParameters, getValidatorContext, setDefaultMessage, setMessageKey, setMessageParameters, setValidatorContext, setValueStackpublic void validate(Object object) throws ValidationException
Validatorobject - the object to be validated.ValidationException - is thrown if there is validation error(s).protected void validateFieldValue(Object object, String value, String regexToUse)
public String getRegex()
public void setRegex(String regex)
regex - the regular expression to be matchedpublic void setRegexExpression(String regexExpression)
regexExpression - the regular expression as an OGNL expression to be matchedpublic boolean isCaseSensitive()
true.public void setCaseSensitive(Boolean caseSensitive)
caseSensitive - whether the expression should be matched against in
 a case-sensitive way.  Default is true.public void setCaseSensitiveExpression(String caseSensitiveExpression)
caseSensitiveExpression - Allows specify caseSensitive param as an OGNL expressionpublic boolean isTrimed()
true.public void setTrim(Boolean trim)
trim - whether the expression should be trimed before matching.
 Default is true.public void setTrimExpression(String trimExpression)
trimExpression - trim param as an OGNL expressionCopyright © 2000–2020 Apache Software Foundation. All rights reserved.