Package com.identity4j.util.validator
Class ListValidator
- java.lang.Object
-
- com.identity4j.util.validator.ListValidator
-
- All Implemented Interfaces:
Validator
public class ListValidator extends Object implements Validator
A validator implementation that checks the supplied values conform to the suppliedMINIMUM_SELECTIONandMAXIMUM_SELECTIONand the values are present in the supplied#LIST_CONTENTS. If theMINIMUM_SELECTION,MAXIMUM_SELECTIONor#LIST_CONTENTSis not specified, the validator uses the default values.
-
-
Field Summary
Fields Modifier and Type Field Description static StringLIST_VALUESParameter which when supplied, specifies the contents of the list.static StringMAXIMUM_SELECTIONParameter which when supplied, specifies the maximum selection for the list.static StringMINIMUM_SELECTIONParameter which when supplied, specifies the minimum selection for the list.static StringTRIMParameter which when supplied, specifies if each value should be preserved or trimmed (String.trim()).
-
Constructor Summary
Constructors Constructor Description ListValidator(MultiMap parameters)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisValueRequired()Get if the validator's rules would mean the a field value is required.StringtoString()Collection<ValidationError>validate(ValidationContext context, String... values)Validate the supplied values, each value is validated individually.
-
-
-
Field Detail
-
LIST_VALUES
public static final String LIST_VALUES
Parameter which when supplied, specifies the contents of the list. If this value is not supplied, the validator does not check the list contents.- See Also:
- Constant Field Values
-
MINIMUM_SELECTION
public static final String MINIMUM_SELECTION
Parameter which when supplied, specifies the minimum selection for the list. If this value is not supplied, the validator defaults to a minimum selection of 0.- See Also:
- Constant Field Values
-
MAXIMUM_SELECTION
public static final String MAXIMUM_SELECTION
Parameter which when supplied, specifies the maximum selection for the list. If this value is not supplied, the validator defaults to a maximum selection of 1.- See Also:
- Constant Field Values
-
TRIM
public static final String TRIM
Parameter which when supplied, specifies if each value should be preserved or trimmed (String.trim()). If this value is not supplied, the validator trims each value.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ListValidator
public ListValidator(MultiMap parameters)
Constructor.- Parameters:
parameters- parameters
-
-
Method Detail
-
validate
public final Collection<ValidationError> validate(ValidationContext context, String... values)
Description copied from interface:ValidatorValidate the supplied values, each value is validated individually.
-
isValueRequired
public boolean isValueRequired()
Description copied from interface:ValidatorGet if the validator's rules would mean the a field value is required. This is a general hint.- Specified by:
isValueRequiredin interfaceValidator- Returns:
- required
-
-