com.opensymphony.xwork2.validator.validators
public class: RequiredFieldValidator [javadoc |
source]
java.lang.Object
com.opensymphony.xwork2.validator.validators.ValidatorSupport
com.opensymphony.xwork2.validator.validators.FieldValidatorSupport
com.opensymphony.xwork2.validator.validators.RequiredFieldValidator
All Implemented Interfaces:
FieldValidator, ShortCircuitableValidator, Validator
RequiredFieldValidator checks if the specified field is not null.
- fieldName - field name if plain-validator syntax is used, not needed if field-validator syntax is used
<validators>
<!-- Plain Validator Syntax -->
<validator type="required">
<param name="fieldName">username</param>
<message>username must not be null</message>
</validator>
<!-- Field Validator Syntax -->
<field name="username">
<field-validator type="required">
<message>username must not be null</message>
</field-validator>
</field>
</validators>
- author:
rainerh -
- version:
$ - Revision: 1063 $
| Method from com.opensymphony.xwork2.validator.validators.RequiredFieldValidator Summary: |
|---|
|
validate |
| 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 |
| Method from com.opensymphony.xwork2.validator.validators.RequiredFieldValidator Detail: |
public void validate(Object object) throws ValidationException {
String fieldName = getFieldName();
Object value = this.getFieldValue(fieldName, object);
if (value == null) {
addFieldError(fieldName, object);
}
}
|