Package org.keycloak.validate
Class AbstractSimpleValidator
java.lang.Object
org.keycloak.validate.AbstractSimpleValidator
- All Implemented Interfaces:
- Provider,- ProviderFactory<Validator>,- SimpleValidator,- Validator,- ValidatorFactory
- Direct Known Subclasses:
- AbstractNumberValidator,- AbstractStringValidator,- UriValidator
Base class for arbitrary value type validators. Functionality covered in this base class:
 
- accepts supported type, collection of supported type.
- behavior around null and empty values is controlled by IGNORE_EMPTY_VALUEconfiguration option which is boolean. Error should be produced for them by default, but they should be ignored if that option istrue. Logic must be implemented inskipValidation(Object, ValidatorConfig).
- Author:
- Vlastimil Elias <velias@redhat.com>
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringConfig option which allows to switch validator to ignore null, empty string and even blank string value - not to produce error for them.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract voiddoValidate(Object value, String inputHint, ValidationContext context, ValidatorConfig config) Validate type, format, range of the value etc.protected booleanDefault implementation only looks forIGNORE_EMPTY_VALUEconfiguration option.protected abstract booleanskipValidation(Object value, ValidatorConfig config) Decide if validation of individual value should be skipped or not.validate(Object input, String inputHint, ValidationContext context, ValidatorConfig config) Validates the giveninputwith an additionalinputHintandconfig.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.keycloak.provider.ProviderFactorygetConfigMetadata, getId, orderMethods inherited from interface org.keycloak.validate.SimpleValidatorclose, create, init, postInitMethods inherited from interface org.keycloak.validate.Validatorvalidate, validate, validate, validate, validateMethods inherited from interface org.keycloak.validate.ValidatorFactoryvalidateConfig
- 
Field Details- 
IGNORE_EMPTY_VALUEConfig option which allows to switch validator to ignore null, empty string and even blank string value - not to produce error for them. Used eg. in UserProfile where we have optional attributes and required concern is checked by separate validators.- See Also:
 
 
- 
- 
Constructor Details- 
AbstractSimpleValidatorpublic AbstractSimpleValidator()
 
- 
- 
Method Details- 
validatepublic ValidationContext validate(Object input, String inputHint, ValidationContext context, ValidatorConfig config) Description copied from interface:ValidatorValidates the giveninputwith an additionalinputHintandconfig.
- 
doValidateprotected abstract void doValidate(Object value, String inputHint, ValidationContext context, ValidatorConfig config) Validate type, format, range of the value etc. Always useValidationContext.addError(ValidationError)to report error to the user! Can be called multiple time for one validation if input is Collection.- Parameters:
- value- to be validated, never null
- inputHint-
- context- for the validation. Add errors into it.
- config- of the validation if provided
- See Also:
 
- 
skipValidationDecide if validation of individual value should be skipped or not. It should be controlled byIGNORE_EMPTY_VALUEconfiguration option, seeisIgnoreEmptyValuesConfigured(ValidatorConfig).- Parameters:
- value- currently validated we make decision for
- config- to look for options in
- Returns:
- true if validation should be skipped for this value -
         doValidate(Object, String, ValidationContext, ValidatorConfig)is not called in this case.
- See Also:
 
- 
isIgnoreEmptyValuesConfiguredDefault implementation only looks forIGNORE_EMPTY_VALUEconfiguration option.- Parameters:
- config- to get option from
- Returns:
 
 
-