Module is.codion.framework.domain
Interface EntityValidator
- All Known Implementing Classes:
DefaultEntityValidator
public interface EntityValidator
Responsible for providing validation for entities.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final is.codion.common.property.PropertyValue<Boolean>Specifies whether the default validator performs strict validation or not. -
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
-
Field Details
-
STRICT_VALIDATION
Specifies whether the default validator performs strict validation or not. By default all non-read-only attribute values are validated if the entity is being inserted (as in, when it does not exist according toEntity.exists()). If the entity exists, only modified values are validated. With strict validation enabled all values are validated, regardless of whether the entity exists or not.
Value type: Boolean
Default value: false
-
-
Method Details
-
nullable
Returns 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.- Type Parameters:
T- the value type- Parameters:
entity- the entity being validatedattribute- the attribute- Returns:
- true if the attribute accepts a null value
-
valid
Returns true if the given entity contains only valid values.- Parameters:
entity- the entity- Returns:
- true if the given entity contains only valid values
-
validate
Checks 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 theSTRICT_VALIDATIONconfiguration value to change the default behaviour.- Parameters:
entity- the entity- Throws:
ValidationException- in case of an invalid value- See Also:
-
validate
Checks if the value associated with the give attribute is valid, throws a ValidationException if not- 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
-