Class MandatoryValidatorImpl
java.lang.Object
ch.tocco.nice2.validate.api.validators.AbstractValidator
ch.tocco.nice2.validate.api.validators.MandatoryValidatorImpl
- All Implemented Interfaces:
MandatoryValidator,Validator,ValueValidator,Cloneable
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.tocco.nice2.validate.api.validators.Validator
Validator.MergeMode -
Field Summary
Fields inherited from class ch.tocco.nice2.validate.api.validators.AbstractValidator
doContinue, level, name, negate, runOn -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected FieldValidationResultbooleanTells if the constraint data of this validator can be merged with another instance.clone()Class<? extends ValueValidator> getType()protected booleanIf subclass overwrites and returns true then the validate() method won't do it anymore.voidinit()protected booleanisEmptySoIgnore(Object value) Subclasses may override this to define what is considered empty, and thus disables the validator.booleanmergeConstraints(Validator validator, Validator.MergeMode mode) Default implementation so that subclasses are only forced to override canMergeConstraints().Methods inherited from class ch.tocco.nice2.validate.api.validators.AbstractValidator
doContinueOnFailure, doNegate, getErrorStatusByLevel, getLevel, getName, getRunOn, hasName, negateResultIfNeeded, setContinue, setLevel, setName, setNegate, setRunOn, validate
-
Constructor Details
-
MandatoryValidatorImpl
public MandatoryValidatorImpl()
-
-
Method Details
-
init
public void init()- Specified by:
initin interfaceMandatoryValidator
-
_validate
protected FieldValidationResult _validate(Object value, Map<String, Object> fields) throws IllegalArgumentException- Specified by:
_validatein classAbstractValidator- Throws:
IllegalArgumentException
-
iNegateMyself
protected boolean iNegateMyself()Description copied from class:AbstractValidatorIf subclass overwrites and returns true then the validate() method won't do it anymore. That's preferred for implementing validators (not groups).- Overrides:
iNegateMyselfin classAbstractValidator- See Also:
-
canMergeConstraints
public boolean canMergeConstraints()Description copied from interface:ValidatorTells if the constraint data of this validator can be merged with another instance.This is validator-type specific. For example a date range validator can, a regex validator obviously cannot.
- Specified by:
canMergeConstraintsin interfaceValidator- See Also:
-
mergeConstraints
Description copied from class:AbstractValidatorDefault implementation so that subclasses are only forced to override canMergeConstraints().- Specified by:
mergeConstraintsin interfaceValidator- Overrides:
mergeConstraintsin classAbstractValidator- Parameters:
validator- The validator to merge in.mode- How to merge.- Returns:
trueif it was done. This should only fail if canMergeConstraints() says false.- See Also:
-
getType
-
isEmptySoIgnore
Description copied from class:AbstractValidatorSubclasses may override this to define what is considered empty, and thus disables the validator.An example is the string field: an empty input string means "no value given".
Imagine a zipcode field that may be empty (if unknown). A length validator (let's say 4 to 10 characters) must be ignored if no input (empty string) was given.
- Overrides:
isEmptySoIgnorein classAbstractValidator- Parameters:
value- The object value as given to validate.- Returns:
- True to disable the validator, false to go on.
-
clone
- Specified by:
clonein interfaceValidator- Overrides:
clonein classAbstractValidator- Throws:
CloneNotSupportedException
-