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 |
static String |
MESSAGE_NUMBER_OUT_OF_RANGE_TOO_BIG |
static String |
MESSAGE_NUMBER_OUT_OF_RANGE_TOO_SMALL |
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 String |
selectRangeErrorMessage(ValidatorConfig config)
Select error message depending on the allowed range interval bound configuration.
|
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, validateclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetHelpTextclose, create, init, postInitvalidate, validate, validate, validate, validate, validategetId, orderpublic static final String MESSAGE_INVALID_NUMBER
public static final String MESSAGE_NUMBER_OUT_OF_RANGE
public static final String MESSAGE_NUMBER_OUT_OF_RANGE_TOO_SMALL
public static final String MESSAGE_NUMBER_OUT_OF_RANGE_TOO_BIG
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 ConfiguredProviderprotected boolean skipValidation(Object value, ValidatorConfig config)
AbstractSimpleValidatorAbstractSimpleValidator.IGNORE_EMPTY_VALUE configuration option, see AbstractSimpleValidator.isIgnoreEmptyValuesConfigured(ValidatorConfig).skipValidation in class AbstractSimpleValidatorvalue - 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)
AbstractSimpleValidatorValidationContext.addError(ValidationError) to
report error to the user! Can be called multiple time for one validation if input is Collection.doValidate in class AbstractSimpleValidatorvalue - to be validated, never nullcontext - for the validation. Add errors into it.config - of the validation if providedAbstractSimpleValidator.skipValidation(Object, ValidatorConfig)protected String selectRangeErrorMessage(ValidatorConfig config)
public ValidationResult validateConfig(KeycloakSession session, ValidatorConfig config)
ValidatorFactory
Implementations can use the KeycloakSession to validate the given ValidatorConfig.
validateConfig in interface ValidatorFactorysession - the KeycloakSessionconfig - 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.