public class RequiredStringValidator extends FieldValidatorSupport
trim
 the String before performing the length check.  If unspecified, the String will be trimmed.
 
 
 
 
     <validators>
         <!-- Plain-Validator Syntax -->
         <validator type="requiredstring">
             <param name="fieldName">username</param>
             <param name="trim">true</param>
             <message>username is required</message>
         </validator>
         
         <!-- Field-Validator Syntax -->
         <field name="username">
                  <field-validator type="requiredstring">
                 <param name="trim">true</param>
                 <message>username is required</message>
            </field-validator>
         </field>
         <!-- Field-Validator Syntax with expression -->
         <field name="username">
                  <field-validator type="requiredstring">
                 <param name="trimExpression">${trimValue}</param> <!-- will be evaluated as: boolean getTrimValue() -->
                 <message>username is required</message>
            </field-validator>
         </field>
     </validators>
 
 currentValue, fieldName, typedefaultMessage, EMPTY_STRING, messageKey, stack, textProviderFactory| Constructor and Description | 
|---|
| RequiredStringValidator() | 
| Modifier and Type | Method and Description | 
|---|---|
| boolean | isTrim() | 
| void | setTrim(boolean trim) | 
| void | setTrimExpression(String trimExpression) | 
| 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 | validateValue(Object object,
             Object fieldValue) | 
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 setTrim(boolean trim)
public void setTrimExpression(String trimExpression)
public boolean isTrim()
public void validate(Object object) throws ValidationException
Validatorobject - the object to be validated.ValidationException - is thrown if there is validation error(s).Copyright © 2000–2025 Apache Software Foundation. All rights reserved.