Package org.keycloak.validate.validators
Class LengthValidator
java.lang.Object
org.keycloak.validate.AbstractSimpleValidator
org.keycloak.validate.AbstractStringValidator
org.keycloak.validate.validators.LengthValidator
- All Implemented Interfaces:
ConfiguredProvider
,Provider
,ProviderFactory<Validator>
,SimpleValidator
,Validator
,ValidatorFactory
String value length validation - accepts plain string and collection of strings, for basic behavior like null/blank
values handling and collections support see
AbstractStringValidator
. Validator trims String value before the
length validation, can be disabled by KEY_TRIM_DISABLED
boolean configuration entry set to
true
.
Configuration have to be always provided, with at least one of KEY_MIN
and KEY_MAX
.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final LengthValidator
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class org.keycloak.validate.AbstractSimpleValidator
IGNORE_EMPTY_VALUE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
doValidate
(String value, String inputHint, ValidationContext context, ValidatorConfig config) getId()
protected String
selectErrorMessage
(ValidatorConfig config) Select error message depending on the allowed length interval bound configuration.validateConfig
(KeycloakSession session, ValidatorConfig config) Validates the given validation config.Methods inherited from class org.keycloak.validate.AbstractStringValidator
doValidate, skipValidation
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
Methods inherited from interface org.keycloak.provider.ProviderFactory
getConfigMetadata, order
Methods inherited from interface org.keycloak.validate.SimpleValidator
close, create, init, postInit
-
Field Details
-
INSTANCE
-
ID
- See Also:
-
MESSAGE_INVALID_LENGTH
- See Also:
-
MESSAGE_INVALID_LENGTH_TOO_SHORT
- See Also:
-
MESSAGE_INVALID_LENGTH_TOO_LONG
- See Also:
-
KEY_MIN
- See Also:
-
KEY_MAX
- See Also:
-
KEY_TRIM_DISABLED
- See Also:
-
-
Constructor Details
-
LengthValidator
public LengthValidator()
-
-
Method Details
-
getId
- Specified by:
getId
in interfaceProviderFactory<Validator>
-
doValidate
protected void doValidate(String value, String inputHint, ValidationContext context, ValidatorConfig config) - Specified by:
doValidate
in classAbstractStringValidator
-
selectErrorMessage
Select error message depending on the allowed length interval bound configuration. -
validateConfig
Description copied from interface:ValidatorFactory
Validates the given validation config.Implementations can use the
KeycloakSession
to validate the givenValidatorConfig
.- Specified by:
validateConfig
in interfaceValidatorFactory
- Parameters:
session
- theKeycloakSession
config
- the config to be validated- Returns:
- the validation result
-
getHelpText
- Specified by:
getHelpText
in interfaceConfiguredProvider
-
getConfigProperties
- Specified by:
getConfigProperties
in interfaceConfiguredProvider
-