public abstract class AbstractNumberValidator extends AbstractSimpleValidator implements ConfiguredProvider
KEY_MIN
and
KEY_MAX
config options.Modifier and Type | Field and Description |
---|---|
protected static List<ProviderConfigProperty> |
configProperties |
static String |
KEY_MAX |
static String |
KEY_MIN |
static String |
MESSAGE_INVALID_NUMBER |
static String |
MESSAGE_NUMBER_OUT_OF_RANGE |
IGNORE_EMPTY_VALUE
Constructor and Description |
---|
AbstractNumberValidator() |
AbstractNumberValidator(ValidatorConfig config) |
Modifier and Type | Method and Description |
---|---|
protected abstract Number |
convert(Object value,
ValidatorConfig config)
Convert input value to instance of Number supported by this validator.
|
protected void |
doValidate(Object value,
String inputHint,
ValidationContext context,
ValidatorConfig config)
Validate type, format, range of the value etc.
|
List<ProviderConfigProperty> |
getConfigProperties() |
protected abstract Number |
getMinMaxConfig(ValidatorConfig config,
String key)
Get config value for min and max validation bound as a Number supported by this validator
|
protected abstract boolean |
isFirstGreaterThanToSecond(Number n1,
Number n2)
Compare two numbers of supported type (fed by
convert(Object, ValidatorConfig) and
getMinMaxConfig(ValidatorConfig, String) ) |
protected boolean |
skipValidation(Object value,
ValidatorConfig config)
Decide if validation of individual value should be skipped or not.
|
ValidationResult |
validateConfig(KeycloakSession session,
ValidatorConfig config)
Validates the given validation config.
|
isIgnoreEmptyValuesConfigured, validate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getHelpText
close, create, init, postInit
validate, validate, validate, validate, validate, validate
getId, order
public static final String MESSAGE_INVALID_NUMBER
public static final String MESSAGE_NUMBER_OUT_OF_RANGE
public static final String KEY_MIN
public static final String KEY_MAX
protected static final List<ProviderConfigProperty> configProperties
public AbstractNumberValidator()
public AbstractNumberValidator(ValidatorConfig config)
public List<ProviderConfigProperty> getConfigProperties()
getConfigProperties
in interface ConfiguredProvider
protected boolean skipValidation(Object value, ValidatorConfig config)
AbstractSimpleValidator
AbstractSimpleValidator.IGNORE_EMPTY_VALUE
configuration option, see AbstractSimpleValidator.isIgnoreEmptyValuesConfigured(ValidatorConfig)
.skipValidation
in class AbstractSimpleValidator
value
- currently validated we make decision forconfig
- to look for options inAbstractSimpleValidator.doValidate(Object, String, ValidationContext, ValidatorConfig)
is not called in this case.AbstractSimpleValidator.doValidate(Object, String, ValidationContext, ValidatorConfig)
protected void doValidate(Object value, String inputHint, ValidationContext context, ValidatorConfig config)
AbstractSimpleValidator
ValidationContext.addError(ValidationError)
to
report error to the user! Can be called multiple time for one validation if input is Collection.doValidate
in class AbstractSimpleValidator
value
- to be validated, never nullcontext
- for the validation. Add errors into it.config
- of the validation if providedAbstractSimpleValidator.skipValidation(Object, ValidatorConfig)
public ValidationResult validateConfig(KeycloakSession session, ValidatorConfig config)
ValidatorFactory
Implementations can use the KeycloakSession
to validate the given ValidatorConfig
.
validateConfig
in interface ValidatorFactory
session
- the KeycloakSession
config
- the config to be validatedprotected abstract Number convert(Object value, ValidatorConfig config)
value
- to convertconfig
- NumberFormatException
- if value is not convertible to supported Number instance so
MESSAGE_INVALID_NUMBER
error is reported.protected abstract Number getMinMaxConfig(ValidatorConfig config, String key)
config
- to get fromkey
- of the config valueprotected abstract boolean isFirstGreaterThanToSecond(Number n1, Number n2)
convert(Object, ValidatorConfig)
and
getMinMaxConfig(ValidatorConfig, String)
)n1
- n2
- Copyright © 2021 JBoss by Red Hat. All rights reserved.