Package org.keycloak.validate.validators
Class IntegerValidator
- java.lang.Object
-
- org.keycloak.validate.AbstractSimpleValidator
-
- org.keycloak.validate.validators.AbstractNumberValidator
-
- org.keycloak.validate.validators.IntegerValidator
-
- All Implemented Interfaces:
ConfiguredProvider
,Provider
,ProviderFactory<Validator>
,SimpleValidator
,Validator
,ValidatorFactory
public class IntegerValidator extends AbstractNumberValidator implements ConfiguredProvider
Validate input being integer numberInteger
orLong
. Accepts String also if convertible toLong
by commonLong.parseLong(String)
operation.- Author:
- Vlastimil Elias
-
-
Field Summary
Fields Modifier and Type Field Description static String
ID
static IntegerValidator
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 IntegerValidator()
IntegerValidator(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 IntegerValidator INSTANCE
-
-
Constructor Detail
-
IntegerValidator
public IntegerValidator()
-
IntegerValidator
public IntegerValidator(ValidatorConfig config)
-
-
Method Detail
-
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
-
getId
public String getId()
- Specified by:
getId
in interfaceProviderFactory<Validator>
-
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
-
-