- java.lang.Object
-
- io.github.mmm.validation.AbstractValidator<V>
-
- io.github.mmm.validation.AbstractComposedValidator<V,V>
-
- io.github.mmm.validation.ComposedValidator<V>
-
- Type Parameters:
V
- is the generic type of the value tovalidate
.
- All Implemented Interfaces:
Composable<Validator<?>>
,Validator<V>
,Iterable<Validator<?>>
public class ComposedValidator<V> extends AbstractComposedValidator<V,V>
Validator
that is composed out of a set of individualvalidators
given atconstruction
. It will always invoke allcontained validators
when avalidation
is performed.- Since:
- 1.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static String
ID
-
Fields inherited from class io.github.mmm.validation.AbstractComposedValidator
children
-
Fields inherited from interface io.github.mmm.validation.Validator
ID_MANDATORY
-
-
Constructor Summary
Constructors Constructor Description ComposedValidator(Validator<? super V>... validators)
The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getId()
AbstractValidator
only provides a default implementation of this method.
ATTENTION:
This default implementation returns thesimple class name
of the actualValidator
implementation.Object
getMax()
Object
getMin()
ValidationResult
validate(V value, Object valueSource)
This method validates the givenvalue
.-
Methods inherited from class io.github.mmm.validation.AbstractComposedValidator
append, append, containsId, equals, getChild, getChildCount, hashCode, validateChild, validateChild
-
Methods inherited from class io.github.mmm.validation.AbstractValidator
isDynamic, source2string, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.github.mmm.base.lang.Composable
iterator
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface io.github.mmm.validation.Validator
isMandatory, validate
-
-
-
-
Field Detail
-
ID
public static final String ID
- See Also:
getId()
, Constant Field Values
-
-
Constructor Detail
-
ComposedValidator
@SafeVarargs public ComposedValidator(Validator<? super V>... validators)
The constructor.
-
-
Method Detail
-
getId
public String getId()
Description copied from class:AbstractValidator
AbstractValidator
only provides a default implementation of this method.
ATTENTION:
This default implementation returns thesimple class name
of the actualValidator
implementation. This strategy is chosen for simplicity when implementing a newValidator
. To ensure stable IDs override this method and return a string constant. This shall at least be done when the name of the class is changed to provide backwards compatibility.- Specified by:
getId
in interfaceValidator<V>
- Overrides:
getId
in classAbstractValidator<V>
- Returns:
- the identifier of this
Validator
. - See Also:
ValidationResult.getCode()
-
validate
public ValidationResult validate(V value, Object valueSource)
Description copied from interface:Validator
This method validates the givenvalue
.- Parameters:
value
- is the value to validate.valueSource
- is thesource
describing the origin of the givenvalue
. The source needs to have a reasonablestring-representation
as this may be displayed to the end-user to locate the source of the failure. In most cases it is suitable to directly pass aString
.- Returns:
- the
ValidationResult
.
-
getMin
public Object getMin()
- Returns:
- the minimum allowed value. Typically of type <V> but this can not be guaranteed.
-
getMax
public Object getMax()
- Returns:
- the maximum allowed value. Typically of type <V> but this can not be guaranteed.
-
-