public class ValidatorMandatory extends AbstractValueValidator<Object>
ValueValidator
that validates that a mandatory value is
filled. It will produce a ValidationFailure
if the value is not
provided (empty, blank, null
).Modifier and Type | Field and Description |
---|---|
static String |
CODE |
private static ValidatorMandatory |
INSTANCE |
Constructor and Description |
---|
ValidatorMandatory()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
protected String |
getCode()
This is the default implementation to retrieve the
code of this
ValueValidator . |
private NlsMessage |
getFailureMessage() |
static ValidatorMandatory |
getInstance() |
boolean |
isMandatory() |
protected NlsMessage |
validateNotNull(Object value)
This method performs the validation in case
value is NOT null . |
protected NlsMessage |
validateNull()
This method performs the validation in case
null was provided as value. |
validate
createBundle, isDynamic, validate
public static final String CODE
getCode()
,
Constant Field Valuesprivate static final ValidatorMandatory INSTANCE
getInstance()
public boolean isMandatory()
isMandatory
in class AbstractValidator<Object>
true
if this is a validator for mandatory fields (that will not accept null
or
empty values), false
otherwise.protected String getCode()
code
of this
ValueValidator
. classname
of the actual
ValueValidator
implementation. This strategy is chosen for simplicity when implementing a new validator. To
ensure stable codes override this method and return a string constant. This shall at least be done when the name of
the class is changed.getCode
in class AbstractValidator<Object>
code
.public static ValidatorMandatory getInstance()
protected NlsMessage validateNull()
null
was provided as value. By default null
should be considered as a legal value. Only for validators such as ValidatorMandatory
this method should be
overridden.validateNull
in class AbstractValueValidator<Object>
failure message
or null
if the null
-value is valid.private NlsMessage getFailureMessage()
protected NlsMessage validateNotNull(Object value)
value
is NOT null
. 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. NlsMessage
instead.validateNotNull
in class AbstractValueValidator<Object>
value
- is the value to validate.failure message
or null
if the the given
value
is valid.Copyright © 2001–2014 mmm-Team. All rights reserved.