Class RequiredValidator
- java.lang.Object
-
- net.sf.jguiraffe.transform.RequiredValidator
-
- All Implemented Interfaces:
Validator
public class RequiredValidator extends Object implements Validator
A specialized
Validator
implementation that checks whether data was entered in mandatory fields.This validator implementation can be assigned to mandatory input fields of different types. When the form is validated it checks if the field contains data. The
isValid()
method is implemented in a generic way supporting multiple data types. Thus this validator can collaborate with input fields of different types. An object passed to theisValid()
method is rejected in any of the following cases:- the object is null
- the object is a string that is empty or contains only whitespace
- the object implements the
Iterable
interface, and the iteration does not contain any elements - the object is an array with no elements
RequiredValidator
does not support any properties. The following table lists the error messages that are generated by this validator class:Message key Description Parameters "ERR_FIELD_REQUIRED"
This input field must contain a value. This is the error code which will be returned when the passed in object is rejected. no parameters An instance of this class can be shared between multiple input components. If additional validations are to be performed for a mandatory input field, a
ChainValidator
can be used that is initialized with aRequiredValidator
and arbitrary other validator implementations.- Version:
- $Id: RequiredValidator.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description RequiredValidator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ValidationResult
isValid(Object o, TransformerContext ctx)
Validates the passed in object.
-
-
-
Method Detail
-
isValid
public ValidationResult isValid(Object o, TransformerContext ctx)
Validates the passed in object. This implementation checks whether the object is defined.
-
-