Package org.keycloak.validate.validators
Class DoubleValidator
- java.lang.Object
-
- org.keycloak.validate.AbstractSimpleValidator
-
- org.keycloak.validate.validators.AbstractNumberValidator
-
- org.keycloak.validate.validators.DoubleValidator
-
- All Implemented Interfaces:
ConfiguredProvider
,Provider
,ProviderFactory<Validator>
,SimpleValidator
,Validator
,ValidatorFactory
public class DoubleValidator extends AbstractNumberValidator implements ConfiguredProvider
Validate input being any kind ofNumber
. Accepts String also if convertible toDouble
by commonDouble.parseDouble(String)
. Min and Max validation is based onDouble
precision also.- Author:
- Vlastimil Elias
-
-
Field Summary
Fields Modifier and Type Field Description static String
ID
static DoubleValidator
INSTANCE
-
Fields inherited from class org.keycloak.validate.validators.AbstractNumberValidator
configProperties, KEY_MAX, KEY_MIN, MESSAGE_INVALID_NUMBER, MESSAGE_NUMBER_OUT_OF_RANGE, MESSAGE_NUMBER_OUT_OF_RANGE_TOO_BIG, MESSAGE_NUMBER_OUT_OF_RANGE_TOO_SMALL
-
Fields inherited from class org.keycloak.validate.AbstractSimpleValidator
IGNORE_EMPTY_VALUE
-
-
Constructor Summary
Constructors Constructor Description DoubleValidator()
DoubleValidator(ValidatorConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Number
convert(Object value, ValidatorConfig config)
Convert input value to instance of Number supported by this validator.String
getHelpText()
String
getId()
protected Number
getMinMaxConfig(ValidatorConfig config, String key)
Get config value for min and max validation bound as a Number supported by this validatorprotected boolean
isFirstGreaterThanToSecond(Number n1, Number n2)
Compare two numbers of supported type (fed byAbstractNumberValidator.convert(Object, ValidatorConfig)
andAbstractNumberValidator.getMinMaxConfig(ValidatorConfig, String)
)-
Methods inherited from class org.keycloak.validate.validators.AbstractNumberValidator
doValidate, getConfigProperties, selectRangeErrorMessage, skipValidation, validateConfig
-
Methods inherited from class org.keycloak.validate.AbstractSimpleValidator
isIgnoreEmptyValuesConfigured, validate
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.keycloak.provider.ConfiguredProvider
getConfig, getConfigProperties
-
Methods inherited from interface org.keycloak.provider.ProviderFactory
getConfigMetadata, order
-
Methods inherited from interface org.keycloak.validate.SimpleValidator
close, create, init, postInit
-
-
-
-
Field Detail
-
ID
public static final String ID
- See Also:
- Constant Field Values
-
INSTANCE
public static final DoubleValidator INSTANCE
-
-
Constructor Detail
-
DoubleValidator
public DoubleValidator()
-
DoubleValidator
public DoubleValidator(ValidatorConfig config)
-
-
Method Detail
-
getId
public String getId()
- Specified by:
getId
in interfaceProviderFactory<Validator>
-
convert
protected Number convert(Object value, ValidatorConfig config)
Description copied from class:AbstractNumberValidator
Convert input value to instance of Number supported by this validator.- Specified by:
convert
in classAbstractNumberValidator
- Parameters:
value
- to convert- Returns:
- value converted to supported Number instance
-
getMinMaxConfig
protected Number getMinMaxConfig(ValidatorConfig config, String key)
Description copied from class:AbstractNumberValidator
Get config value for min and max validation bound as a Number supported by this validator- Specified by:
getMinMaxConfig
in classAbstractNumberValidator
- Parameters:
config
- to get fromkey
- of the config value- Returns:
- bound value or null
-
isFirstGreaterThanToSecond
protected boolean isFirstGreaterThanToSecond(Number n1, Number n2)
Description copied from class:AbstractNumberValidator
Compare two numbers of supported type (fed byAbstractNumberValidator.convert(Object, ValidatorConfig)
andAbstractNumberValidator.getMinMaxConfig(ValidatorConfig, String)
)- Specified by:
isFirstGreaterThanToSecond
in classAbstractNumberValidator
- Returns:
- true if first number is greater than second
-
getHelpText
public String getHelpText()
- Specified by:
getHelpText
in interfaceConfiguredProvider
-
-