Module is.codion.framework.domain
Class DefaultEntityValidator
java.lang.Object
is.codion.framework.domain.entity.DefaultEntityValidator
- All Implemented Interfaces:
EntityValidator,Serializable
A default
EntityValidator implementation providing null validation for attributes marked as not null,
item validation for item based attributes, range validation for numerical attributes with max and/or min values
specified and string length validation based on the specified max length.
This Validator can be extended to provide further validation.-
Field Summary
Fields inherited from interface is.codion.framework.domain.entity.EntityValidator
STRICT_VALIDATION -
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a new DefaultEntityValidatorDefaultEntityValidator(boolean strictValidation) Instantiates a new DefaultEntityValidator -
Method Summary
Modifier and TypeMethodDescription<T> booleanReturns true if the value based on the given attribute accepts a null value for the given entity, by default this method simply returns the nullable state of the underlying attribute.booleanReturns true if the given entity contains only valid values.voidChecks if the values in the given entity are valid.<T> voidChecks if the value associated with the give attribute is valid, throws a ValidationException if not
-
Constructor Details
-
DefaultEntityValidator
public DefaultEntityValidator()Instantiates a new DefaultEntityValidator- See Also:
-
DefaultEntityValidator
public DefaultEntityValidator(boolean strictValidation) Instantiates a new DefaultEntityValidator- Parameters:
strictValidation- true if strict validation should be performed- See Also:
-
-
Method Details
-
valid
Description copied from interface:EntityValidatorReturns true if the given entity contains only valid values.- Specified by:
validin interfaceEntityValidator- Parameters:
entity- the entity- Returns:
- true if the given entity contains only valid values
-
nullable
Description copied from interface:EntityValidatorReturns true if the value based on the given attribute accepts a null value for the given entity, by default this method simply returns the nullable state of the underlying attribute.- Specified by:
nullablein interfaceEntityValidator- Type Parameters:
T- the value type- Parameters:
entity- the entity being validatedattribute- the attribute- Returns:
- true if the attribute accepts a null value
-
validate
Description copied from interface:EntityValidatorChecks if the values in the given entity are valid. Note that by default, if the entity instance does not exist according toEntity.exists()all values are validated, otherwise only modified values are validated. Use theEntityValidator.STRICT_VALIDATIONconfiguration value to change the default behaviour.- Specified by:
validatein interfaceEntityValidator- Parameters:
entity- the entity- Throws:
ValidationException- in case of an invalid value- See Also:
-
validate
Description copied from interface:EntityValidatorChecks if the value associated with the give attribute is valid, throws a ValidationException if not- Specified by:
validatein interfaceEntityValidator- Type Parameters:
T- the value type- Parameters:
entity- the entity to validateattribute- the attribute the value is associated with- Throws:
ValidationException- if the given value is not valid for the given attribute
-