Class GroupValidatorView
- All Implemented Interfaces:
GroupValidator,Validator,Cloneable,Iterable<Validator>
GroupValidator.
An example is a "server" view, where only validation rules are visible that run on the server.
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.tocco.nice2.validate.api.validators.Validator
Validator.MergeMode -
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.voidaddValidators(Collection<Validator> validators) booleanTells if the constraint data of this validator can be merged with another instance.clone()booleanIf the validation process should continue on this level with next validator when this one "fails".booleandoNegate()Tells if the result of the validation is being negated (internally).@Nullable ValidatorFinds a child validator, either a direct child or somewhere down the hierarchy, with the given name path.getLevel()@Nullable StringgetName()getRunOn()getType()Returns a list with the validators in this group.booleanhasName()booleaniterator()booleanmergeConstraints(Validator validator, Validator.MergeMode mode) Merges the constraint data of this validator with the data of another instance.booleanmergeInValidatorByName(String name, Validator validator, Validator.MergeMode mode) 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.voidsetContinue(boolean doContinue) voidsetLevel(ErrorLevel level) voidvoidsetNegate(boolean negate) voidValidates a data component, for example a field or a group of fields.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
GroupValidatorView
-
-
Method Details
-
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
-
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
-
mergeInValidatorByName
-
addValidators
-
validate
public FieldValidationResult validate(Object value, Map<String, Object> fields) throws IllegalArgumentExceptionDescription copied from interface:ValidatorValidates a data component, for example a field or a group of fields.The fields map is required for looking at other values of this entity/form when conditions are in use.
With this definition we don't know which value in the fields map is "us", cause we dont' know our name here. Don't think it's needed.
Groups: if there are no (active) validators in this group then the OK status is returned.
- Specified by:
validatein interfaceValidator- Parameters:
value- the value to validate, non-nullfields- (all fields, key=name, value=value plus type)- Throws:
IllegalArgumentException- Wrong data type.
-
doNegate
public boolean doNegate()Description copied from interface:ValidatorTells if the result of the validation is being negated (internally). This means that the properties of specific validator implementations like a number range have negated meaning in the end. -
setNegate
public void setNegate(boolean negate) -
hasName
public boolean hasName() -
getName
-
setName
-
getLevel
-
setLevel
-
getRunOn
-
setRunOn
-
doContinueOnFailure
public boolean doContinueOnFailure()Description copied from interface:ValidatorIf the validation process should continue on this level with next validator when this one "fails". Failing means a negative result, how negative depends on ghe error level, an INFO counts as failed too (the test failed, it's just not that important).- Specified by:
doContinueOnFailurein interfaceValidator- Returns:
- .
-
setContinue
public void setContinue(boolean doContinue) - Specified by:
setContinuein interfaceValidator
-
getType
-
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 interface:ValidatorMerges the constraint data of this validator with the data of another instance.- Specified by:
mergeConstraintsin interfaceValidator- 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:
-
clone
- Specified by:
clonein interfaceValidator- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
iterator
-