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
 
 public class LengthValidator extends AbstractStringValidator implements ConfiguredProvider String value length validation - accepts plain string and collection of strings, for basic behavior like null/blank values handling and collections support seeAbstractStringValidator. Validator trims String value before the length validation, can be disabled byKEY_TRIM_DISABLEDboolean configuration entry set totrue.Configuration have to be always provided, with at least one of KEY_MINandKEY_MAX.
- 
- 
Field SummaryFields Modifier and Type Field Description static StringIDstatic LengthValidatorINSTANCEstatic StringKEY_MAXstatic StringKEY_MINstatic StringKEY_TRIM_DISABLEDstatic StringMESSAGE_INVALID_LENGTHstatic StringMESSAGE_INVALID_LENGTH_TOO_LONGstatic StringMESSAGE_INVALID_LENGTH_TOO_SHORT- 
Fields inherited from class org.keycloak.validate.AbstractSimpleValidatorIGNORE_EMPTY_VALUE
 
- 
 - 
Constructor SummaryConstructors Constructor Description LengthValidator()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoValidate(String value, String inputHint, ValidationContext context, ValidatorConfig config)List<ProviderConfigProperty>getConfigProperties()StringgetHelpText()StringgetId()protected StringselectErrorMessage(ValidatorConfig config)Select error message depending on the allowed length interval bound configuration.ValidationResultvalidateConfig(KeycloakSession session, ValidatorConfig config)Validates the given validation config.- 
Methods inherited from class org.keycloak.validate.AbstractStringValidatordoValidate, skipValidation
 - 
Methods inherited from class org.keycloak.validate.AbstractSimpleValidatorisIgnoreEmptyValuesConfigured, validate
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.keycloak.provider.ConfiguredProvidergetConfig
 - 
Methods inherited from interface org.keycloak.provider.ProviderFactorygetConfigMetadata, order
 - 
Methods inherited from interface org.keycloak.validate.SimpleValidatorclose, create, init, postInit
 
- 
 
- 
- 
- 
Field Detail- 
INSTANCEpublic static final LengthValidator INSTANCE 
 - 
IDpublic static final String ID - See Also:
- Constant Field Values
 
 - 
MESSAGE_INVALID_LENGTHpublic static final String MESSAGE_INVALID_LENGTH - See Also:
- Constant Field Values
 
 - 
MESSAGE_INVALID_LENGTH_TOO_SHORTpublic static final String MESSAGE_INVALID_LENGTH_TOO_SHORT - See Also:
- Constant Field Values
 
 - 
MESSAGE_INVALID_LENGTH_TOO_LONGpublic static final String MESSAGE_INVALID_LENGTH_TOO_LONG - See Also:
- Constant Field Values
 
 - 
KEY_MINpublic static final String KEY_MIN - See Also:
- Constant Field Values
 
 - 
KEY_MAXpublic static final String KEY_MAX - See Also:
- Constant Field Values
 
 - 
KEY_TRIM_DISABLEDpublic static final String KEY_TRIM_DISABLED - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getIdpublic String getId() - Specified by:
- getIdin interface- ProviderFactory<Validator>
 
 - 
doValidateprotected void doValidate(String value, String inputHint, ValidationContext context, ValidatorConfig config) - Specified by:
- doValidatein class- AbstractStringValidator
 
 - 
selectErrorMessageprotected String selectErrorMessage(ValidatorConfig config) Select error message depending on the allowed length interval bound configuration.
 - 
validateConfigpublic ValidationResult validateConfig(KeycloakSession session, ValidatorConfig config) Description copied from interface:ValidatorFactoryValidates the given validation config.Implementations can use the KeycloakSessionto validate the givenValidatorConfig.- Specified by:
- validateConfigin interface- ValidatorFactory
- Parameters:
- session- the- KeycloakSession
- config- the config to be validated
- Returns:
- the validation result
 
 - 
getHelpTextpublic String getHelpText() - Specified by:
- getHelpTextin interface- ConfiguredProvider
 
 - 
getConfigPropertiespublic List<ProviderConfigProperty> getConfigProperties() - Specified by:
- getConfigPropertiesin interface- ConfiguredProvider
 
 
- 
 
-