Interface Validator
- All Superinterfaces:
Cloneable
- All Known Subinterfaces:
AndGroupValidator
,DecimalDigitsValidator
,EmailValidator
,GroupValidator
,IbanValidator
,LengthValidator
,MandatoryValidator
,NumberRangeValidator
,PhoneValidator
,RegexValidator
,SocialSecurityNrValidator
,UrlValidator
,ValueValidator
- All Known Implementing Classes:
AbstractGroupValidator
,AbstractValidator
,AndGroupValidatorImpl
,DecimalDigitsValidatorImpl
,EmailValidatorImpl
,GroupValidatorView
,IbanValidatorImpl
,LengthValidatorImpl
,MandatoryValidatorImpl
,NumberRangeValidatorImpl
,PhoneValidatorImpl
,RegexValidatorImpl
,SocialSecurityNrValidatorImpl
,UrlValidatorImpl
A validator to check if data matches expected rules.
This validator is used for form input and entity data, maybe more to come.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Defines how to merge the constraint properties of two validators. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Tells if the constraint data of this validator can be merged with another instance.clone()
boolean
If the validation process should continue on this level with next validator when this one "fails".boolean
doNegate()
Tells if the result of the validation is being negated (internally).getLevel()
@Nullable String
getName()
getRunOn()
getType()
boolean
hasName()
boolean
mergeConstraints
(Validator validator, Validator.MergeMode mode) Merges the constraint data of this validator with the data of another instance.void
setContinue
(boolean doContinue) void
setLevel
(ErrorLevel level) void
void
setNegate
(boolean negate) void
Validates a data component, for example a field or a group of fields.
-
Method Details
-
validate
FieldValidationResult validate(Object value, Map<String, Object> fields) throws IllegalArgumentExceptionValidates 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.
- Parameters:
value
- the value to validate, non-nullfields
- (all fields, key=name, value=value plus type)- Throws:
IllegalArgumentException
- Wrong data type.
-
doNegate
boolean doNegate()Tells 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.- Returns:
- .
-
setNegate
void setNegate(boolean negate) -
hasName
boolean hasName()- Returns:
- Tells if this validator has a name, otherwise it is null.
-
getName
-
setName
-
getLevel
ErrorLevel getLevel() -
setLevel
-
getRunOn
RunOn getRunOn() -
setRunOn
-
doContinueOnFailure
boolean doContinueOnFailure()If 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).- Returns:
- .
-
setContinue
void setContinue(boolean doContinue) -
getType
- Returns:
- The class of the implementing class.
-
canMergeConstraints
boolean canMergeConstraints()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.
- See Also:
-
mergeConstraints
Merges the constraint data of this validator with the data of another instance.- 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:
-
clone
- Throws:
CloneNotSupportedException
-