Class AbstractGroupValidator
- All Implemented Interfaces:
GroupValidator,Validator,Cloneable,Iterable<Validator>
- Direct Known Subclasses:
AndGroupValidatorImpl
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.tocco.nice2.validate.api.validators.Validator
Validator.MergeMode -
Field Summary
FieldsFields inherited from class ch.tocco.nice2.validate.api.validators.AbstractValidator
doContinue, level, name, negate, runOn -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddValidator(Validator validator) Adds a validator to the group.voidaddValidator(Validator validator, boolean respectLevelOrder) Adds a validator to the group in the right position.booleanTells if the constraint data of this validator can be merged with another instance.clone()@Nullable ValidatorFinds a child validator, either a direct child or somewhere down the hierarchy, with the given name path.getType()Returns a list with the validators in this group.booleanprotected booleanisEmptySoIgnore(Object value) Subclasses may override this to define what is considered empty, and thus disables the validator.iterator()booleanmergeInValidatorByType(Validator validator, Validator.MergeMode mode) Tells an existing validator of that type (with same level and no conditions) to merge in the attributes of the given one, or adds the passed validator if no such is here yet.voidremoveValidator(Validator validator) Remove a validator to the group.Methods inherited from class ch.tocco.nice2.validate.api.validators.AbstractValidator
_validate, doContinueOnFailure, doNegate, getErrorStatusByLevel, getLevel, getName, getRunOn, hasName, iNegateMyself, mergeConstraints, negateResultIfNeeded, setContinue, setLevel, setName, setNegate, setRunOn, validateMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface ch.tocco.nice2.validate.api.validators.Validator
doContinueOnFailure, doNegate, getLevel, getName, getRunOn, hasName, mergeConstraints, setContinue, setLevel, setName, setNegate, setRunOn, validate
-
Field Details
-
validators
Validators and Groups.Mostly in the order that ERROR level validators come before WARN come before INFO. It seems easier atm to work with just one simple list.
-
-
Constructor Details
-
AbstractGroupValidator
public AbstractGroupValidator()
-
-
Method Details
-
addValidator
Description copied from interface:GroupValidatorAdds a validator to the group.- Specified by:
addValidatorin interfaceGroupValidator- Parameters:
validator- validator, non-null
-
removeValidator
Description copied from interface:GroupValidatorRemove a validator to the group.- Specified by:
removeValidatorin interfaceGroupValidator- Parameters:
validator- validator, non-null
-
addValidator
Description copied from interface:GroupValidatorAdds a validator to the group in the right position.Validators of error level ERROR need to come before WARN need to come before INFO. The xml model reader makes sure the validators are given in the right order. But once manual customization, as well as merging comes in, this is required.
- Specified by:
addValidatorin interfaceGroupValidator
-
mergeInValidatorByType
Description copied from interface:GroupValidatorTells an existing validator of that type (with same level and no conditions) to merge in the attributes of the given one, or adds the passed validator if no such is here yet.- Specified by:
mergeInValidatorByTypein interfaceGroupValidator- Parameters:
validator- The validator to merge in.mode- .- Returns:
- true if it was merged, false if it was added
-
hasValidators
public boolean hasValidators()- Specified by:
hasValidatorsin interfaceGroupValidator- Returns:
- Tells if this group has any validators.
-
getValidators
Description copied from interface:GroupValidatorReturns a list with the validators in this group.- Specified by:
getValidatorsin interfaceGroupValidator- Returns:
- list may be empty
-
findChild
Description copied from interface:GroupValidatorFinds a child validator, either a direct child or somewhere down the hierarchy, with the given name path.If you are looking for a direct child then specify the name, eg "myLengthValidator".
If you're looking for one down in a group then use the path, eg "myAndGroup.myLengthConditionalGroup.myLengthValidator".- Specified by:
findChildin interfaceGroupValidator
-
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:
-
getType
-
iterator
-
clone
- Specified by:
clonein interfaceValidator- Overrides:
clonein classAbstractValidator- Throws:
CloneNotSupportedException
-
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.
-