Save This Page
Home » xwork-2.1.1-src » com.opensymphony.xwork2.validator.validators » [javadoc | source]
com.opensymphony.xwork2.validator.validators
public class: StringLengthFieldValidator [javadoc | source]
java.lang.Object
   com.opensymphony.xwork2.validator.validators.ValidatorSupport
      com.opensymphony.xwork2.validator.validators.FieldValidatorSupport
         com.opensymphony.xwork2.validator.validators.StringLengthFieldValidator

All Implemented Interfaces:
    FieldValidator, ShortCircuitableValidator, Validator

StringLengthFieldValidator checks that a String field is of a certain length. If the "minLength" parameter is specified, it will make sure that the String has at least that many characters. If the "maxLength" parameter is specified, it will make sure that the String has at most that many characters. The "trim" parameter determines whether it will trim the String before performing the length check. If unspecified, the String will be trimmed.


<validators>
<!-- Plain Validator Syntax -->
<validator type="stringlength">
<param name="fieldName">myPurchaseCode</param>
<param name="minLength">10</param>
<param name="maxLength">10</param>
<param name="trim">true</param>
<message>Your purchase code needs to be 10 characters long</message>
</validator>

<!-- Field Validator Syntax -->
<field name="myPurchaseCode">
<param name="minLength">10</param>
<param name="maxLength>10</param>
<param name="trim">true</param>
<message>Your purchase code needs to be 10 characters long</message>
</field>
</validators>

Fields inherited from com.opensymphony.xwork2.validator.validators.ValidatorSupport:
log,  defaultMessage,  messageKey
Method from com.opensymphony.xwork2.validator.validators.StringLengthFieldValidator Summary:
getMaxLength,   getMinLength,   getTrim,   setMaxLength,   setMinLength,   setTrim,   validate
Methods from com.opensymphony.xwork2.validator.validators.FieldValidatorSupport:
getFieldName,   getValidatorType,   setFieldName,   setValidatorType
Methods from com.opensymphony.xwork2.validator.validators.ValidatorSupport:
addActionError,   addFieldError,   conditionalParse,   getDefaultMessage,   getFieldValue,   getMessage,   getMessageKey,   getParse,   getValidatorContext,   getValidatorType,   isShortCircuit,   setDefaultMessage,   setMessageKey,   setParse,   setShortCircuit,   setValidatorContext,   setValidatorType,   setValueStack
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.opensymphony.xwork2.validator.validators.StringLengthFieldValidator Detail:
 public int getMaxLength() 
 public int getMinLength() 
 public boolean getTrim() 
 public  void setMaxLength(int maxLength) 
 public  void setMinLength(int minLength) 
 public  void setTrim(boolean trim) 
 public  void validate(Object object) throws ValidationException