public abstract class AbstractSimpleValidator extends Object implements SimpleValidator
IGNORE_EMPTY_VALUE
configuration option which is
boolean. Error should be produced for them by default, but they should be ignored if that option is
true
. Logic must be implemented in skipValidation(Object, ValidatorConfig)
.
Modifier and Type | Field and Description |
---|---|
static String |
IGNORE_EMPTY_VALUE
Config option which allows to switch validator to ignore null, empty string and even blank string value - not to
produce error for them.
|
Constructor and Description |
---|
AbstractSimpleValidator() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
doValidate(Object value,
String inputHint,
ValidationContext context,
ValidatorConfig config)
Validate type, format, range of the value etc.
|
protected boolean |
isIgnoreEmptyValuesConfigured(ValidatorConfig config)
Default implementation only looks for
IGNORE_EMPTY_VALUE configuration option. |
protected abstract boolean |
skipValidation(Object value,
ValidatorConfig config)
Decide if validation of individual value should be skipped or not.
|
ValidationContext |
validate(Object input,
String inputHint,
ValidationContext context,
ValidatorConfig config)
Validates the given
input with an additional inputHint and config . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, create, init, postInit
validate, validate, validate, validate, validate, validate
validateConfig
getId, order
public static final String IGNORE_EMPTY_VALUE
public ValidationContext validate(Object input, String inputHint, ValidationContext context, ValidatorConfig config)
Validator
input
with an additional inputHint
and config
.protected abstract void doValidate(Object value, String inputHint, ValidationContext context, ValidatorConfig config)
ValidationContext.addError(ValidationError)
to
report error to the user! Can be called multiple time for one validation if input is Collection.value
- to be validated, never nullinputHint
- context
- for the validation. Add errors into it.config
- of the validation if providedskipValidation(Object, ValidatorConfig)
protected abstract boolean skipValidation(Object value, ValidatorConfig config)
IGNORE_EMPTY_VALUE
configuration option, see isIgnoreEmptyValuesConfigured(ValidatorConfig)
.value
- currently validated we make decision forconfig
- to look for options indoValidate(Object, String, ValidationContext, ValidatorConfig)
is not called in this case.doValidate(Object, String, ValidationContext, ValidatorConfig)
protected boolean isIgnoreEmptyValuesConfigured(ValidatorConfig config)
IGNORE_EMPTY_VALUE
configuration option.config
- to get option fromCopyright © 2021 JBoss by Red Hat. All rights reserved.