Class LengthValidatorImpl
java.lang.Object
ch.tocco.nice2.validate.api.validators.AbstractValidator
ch.tocco.nice2.validate.api.validators.LengthValidatorImpl
- All Implemented Interfaces:
LengthValidator
,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
ConstructorDescriptionLengthValidatorImpl
(@Nullable Integer fromIncluding, @Nullable Integer toIncluding) -
Method Summary
Modifier and TypeMethodDescriptionprotected FieldValidationResult
boolean
Tells if the constraint data of this validator can be merged with another instance.clone()
Returns the length min value which is valid including this value, or null if none specified.Returns the length max value which is valid including this value, or null if none specified.Class
<? extends ValueValidator> getType()
protected boolean
If subclass overwrites and returns true then the validate() method won't do it anymore.void
boolean
mergeConstraints
(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, isEmptySoIgnore, negateResultIfNeeded, setContinue, setLevel, setName, setNegate, setRunOn, validate
-
Constructor Details
-
LengthValidatorImpl
public LengthValidatorImpl() -
LengthValidatorImpl
-
-
Method Details
-
init
public void init(@Nullable @Nullable Integer fromIncluding, @Nullable @Nullable Integer toIncluding) - Specified by:
init
in interfaceLengthValidator
-
getFromIncluding
Description copied from interface:LengthValidator
Returns the length min value which is valid including this value, or null if none specified.- Specified by:
getFromIncluding
in interfaceLengthValidator
-
getToIncluding
Description copied from interface:LengthValidator
Returns the length max value which is valid including this value, or null if none specified.- Specified by:
getToIncluding
in interfaceLengthValidator
-
_validate
protected FieldValidationResult _validate(Object value, Map<String, Object> fields) throws IllegalArgumentException- Specified by:
_validate
in classAbstractValidator
- Throws:
IllegalArgumentException
-
iNegateMyself
protected boolean iNegateMyself()Description copied from class:AbstractValidator
If subclass overwrites and returns true then the validate() method won't do it anymore. That's preferred for implementing validators (not groups).- Overrides:
iNegateMyself
in classAbstractValidator
- See Also:
-
canMergeConstraints
public boolean canMergeConstraints()Description copied from interface:Validator
Tells 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:
canMergeConstraints
in interfaceValidator
- See Also:
-
mergeConstraints
Description copied from class:AbstractValidator
Default implementation so that subclasses are only forced to override canMergeConstraints().- Specified by:
mergeConstraints
in interfaceValidator
- Overrides:
mergeConstraints
in classAbstractValidator
- Parameters:
validator
- The validator to merge in.mode
- How to merge.- Returns:
true
if it was done. This should only fail if canMergeConstraints() says false.- See Also:
-
getType
-
clone
- Specified by:
clone
in interfaceValidator
- Overrides:
clone
in classAbstractValidator
- Throws:
CloneNotSupportedException
-