Class BasePropertyValidation
- java.lang.Object
-
- org.cyclos.impl.utils.validation.validations.BasePropertyValidation
-
- All Implemented Interfaces:
PropertyValidation
- Direct Known Subclasses:
BaseLengthValidation,BasePeriodValidation,CharacterEncodingValidation,ChildValidation,ColorValidation,ComparableValidation,ContainedInValidation,DateValidation,EmailValidation,FutureDateValidation,IdentifierValidation,InternetAddressListValidation,InternetAddressValidation,InvalidValidation,LatLongValidation,MaskValueValidation,MaxElementsValidation,MaxWordSizeValidation,MinElementsValidation,MustBeInstanceOfValidation,NegativeNonZeroValidation,NegativeOrZeroValidation,NoneOfValidation,NotContainsValidation,NoUrlValidation,PasswordServiceImpl.CharsetValidation,PastDateValidation,PositiveNonZeroValidation,PositiveOrZeroValidation,RangeValidation,RegexValidation,RequiredValidation,SignalValidation,UniqueValidation,UrlValidation
public abstract class BasePropertyValidation extends Object implements PropertyValidation
Base class forPropertyValidations. Receive on the constructor aValidationErrorthat will be returned when there are errors. Defines theisValid(Object, Object, Object)method that should be implemented in order to check if the given value is valid.
-
-
Field Summary
Fields Modifier and Type Field Description protected ValidationErrorerror
-
Constructor Summary
Constructors Constructor Description BasePropertyValidation()Without specifying aValidationError,ValidationErrors.invalid()is assumedBasePropertyValidation(ValidationError error)Uses the givenValidationErrorBasePropertyValidation(MessageKey key)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected ConversionHandlergetConversionHandler()protected EntityManagerHandlergetEntityManagerHandler()Returns anEntityManagerHandlerwhich can be used by validations which need database accessprotected booleanhandleEmpty()May be overridden in order to indicate that empty values should be validatedprotected abstract booleanisValid(Object object, Object property, Object value)Should be implemented to return whether the value is valid.ValidationErrorvalidate(Object object, Object property, Object value)Validates a property value
-
-
-
Field Detail
-
error
protected ValidationError error
-
-
Constructor Detail
-
BasePropertyValidation
public BasePropertyValidation()
Without specifying aValidationError,ValidationErrors.invalid()is assumed
-
BasePropertyValidation
public BasePropertyValidation(MessageKey key)
-
BasePropertyValidation
public BasePropertyValidation(ValidationError error)
Uses the givenValidationError
-
-
Method Detail
-
validate
public final ValidationError validate(Object object, Object property, Object value)
Description copied from interface:PropertyValidationValidates a property value- Specified by:
validatein interfacePropertyValidation- Parameters:
object- The objectproperty- The property name or descriptorvalue- The property value- Returns:
- An error if there is an error, or null when is valid
-
getConversionHandler
protected ConversionHandler getConversionHandler()
-
getEntityManagerHandler
protected EntityManagerHandler getEntityManagerHandler()
Returns anEntityManagerHandlerwhich can be used by validations which need database access
-
handleEmpty
protected boolean handleEmpty()
May be overridden in order to indicate that empty values should be validated
-
isValid
protected abstract boolean isValid(Object object, Object property, Object value)
Should be implemented to return whether the value is valid. If the value is valid, thevalidate(Object, Object, Object)method will return null. Otherwise, will return theValidationErrorreceived on the constructor (or a general validation error if none was passed)
-
-