- java.lang.Object
-
- io.github.mmm.validation.AbstractValidator<V>
-
- io.github.mmm.validation.AbstractValueValidator<Object>
-
- io.github.mmm.validation.main.ValidatorMandatory
-
public class ValidatorMandatory extends AbstractValueValidator<Object>
Validator
validating that a mandatory value is filled.ValidationResult
will be invalid if the value is not provided (empty, blank,null
).- Since:
- 1.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static String
ID
-
Fields inherited from interface io.github.mmm.validation.Validator
ID_MANDATORY
-
-
Constructor Summary
Constructors Constructor Description ValidatorMandatory()
The constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ValidatorMandatory
get()
String
getId()
AbstractValidator
only provides a default implementation of this method.
ATTENTION:
This default implementation returns thesimple class name
of the actualValidator
implementation.boolean
isMandatory()
protected NlsMessage
validateNotNull(Object value)
This method performs the validation in casevalue
is NOTnull
.protected NlsMessage
validateNull()
This method performs the validation in casenull
was provided as value.-
Methods inherited from class io.github.mmm.validation.AbstractValueValidator
validate
-
Methods inherited from class io.github.mmm.validation.AbstractValidator
equals, hashCode, 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
getChild, getChildCount, iterator
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
ID
public static final String ID
- See Also:
getId()
, Constant Field Values
-
-
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<Object>
- Overrides:
getId
in classAbstractValidator<Object>
- Returns:
- the identifier of this
Validator
. - See Also:
ValidationResult.getCode()
-
get
public static ValidatorMandatory get()
- Returns:
- the singleton instance of this class.
-
validateNull
protected NlsMessage validateNull()
Description copied from class:AbstractValueValidator
This method performs the validation in casenull
was provided as value. By defaultnull
should be considered as a legal value. Only for validators such asmandatory validator
this method should be overridden.- Overrides:
validateNull
in classAbstractValueValidator<Object>
- Returns:
- the
failure message
ornull
ifnull
is valid.
-
validateNotNull
protected NlsMessage validateNotNull(Object value)
Description copied from class:AbstractValueValidator
This method performs the validation in casevalue
is NOTnull
. This method contains the actual custom logic for the validation. It is therefore designed in a way that makes it most simple to implement custom validators.- Specified by:
validateNotNull
in classAbstractValueValidator<Object>
- Parameters:
value
- the value to validate.- Returns:
- the
failure message
ornull
if the the givenvalue
is valid.
-
isMandatory
public final boolean isMandatory()
- Returns:
true
if this is a validator for mandatory fields (that will not acceptnull
or empty values),false
otherwise.
-
-