org.keycloak.validate

## Class AbstractStringValidator

- java.lang.Object
- - org.keycloak.validate.AbstractSimpleValidator
  - - org.keycloak.validate.AbstractStringValidator

- All Implemented Interfaces:
    Provider, ProviderFactory<Validator>, SimpleValidator, Validator, ValidatorFactory
  Direct Known Subclasses:
    EmailValidator, LengthValidator, LocalDateValidator, PatternValidator

      public abstract class AbstractStringValidator
      extends AbstractSimpleValidator

  Base class for String value format validators. Functionality covered in this base class:
  - accepts plain string and collections of strings as input
  - each item is validated for collections of strings by `doValidate(String, String, ValidationContext, ValidatorConfig)`
  - null and empty values behavior should follow config, see `AbstractSimpleValidator` javadoc.
  Author:
    Vlastimil Elias

- - ### Field Summary

    - ### Fields inherited from class org.keycloak.validate.AbstractSimpleValidator

      `IGNORE_EMPTY_VALUE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractStringValidator()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `doValidate(Object value, String inputHint, ValidationContext context, ValidatorConfig config)` Validate type, format, range of the value etc.
    `protected abstract void` | `doValidate(String value, String inputHint, ValidationContext context, ValidatorConfig config)`
    `protected boolean` | `skipValidation(Object value, ValidatorConfig config)` Decide if validation of individual value should be skipped or not.

    - ### 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.validate.SimpleValidator

      `close, create, init, postInit`

    - ### Methods inherited from interface org.keycloak.validate.Validator

      `validate, validate, validate, validate, validate, validate`

    - ### Methods inherited from interface org.keycloak.validate.ValidatorFactory

      `validateConfig`

    - ### Methods inherited from interface org.keycloak.provider.ProviderFactory

      `getId, order`

- - ### Constructor Detail

    - #### AbstractStringValidator

          public AbstractStringValidator()

  - ### Method Detail

    - #### doValidate

          protected void doValidate(Object value,
                                    String inputHint,
                                    ValidationContext context,
                                    ValidatorConfig config)

      Description copied from class: `AbstractSimpleValidator`
      Validate type, format, range of the value etc. Always use `ValidationContext.addError(ValidationError)` to report error to the user! Can be called multiple time for one validation if input is Collection.
      Specified by:
        `doValidate` in class `AbstractSimpleValidator`
      Parameters:
        `value` - to be validated, never null
        `context` - for the validation. Add errors into it.
        `config` - of the validation if provided
      See Also:
        `AbstractSimpleValidator.skipValidation(Object, ValidatorConfig)`

    - #### doValidate

          protected abstract void doValidate(String value,
                                             String inputHint,
                                             ValidationContext context,
                                             ValidatorConfig config)

    - #### skipValidation

          protected boolean skipValidation(Object value,
                                           ValidatorConfig config)

      Description copied from class: `AbstractSimpleValidator`
      Decide if validation of individual value should be skipped or not. It should be controlled by `AbstractSimpleValidator.IGNORE_EMPTY_VALUE` configuration option, see `AbstractSimpleValidator.isIgnoreEmptyValuesConfigured(ValidatorConfig)`.
      Specified by:
        `skipValidation` in class `AbstractSimpleValidator`
      Parameters:
        `value` - currently validated we make decision for
        `config` - to look for options in
      Returns:
        true if validation should be skipped for this value - `AbstractSimpleValidator.doValidate(Object, String, ValidationContext, ValidatorConfig)` is not called in this case.
      See Also:
        `AbstractSimpleValidator.doValidate(Object, String, ValidationContext, ValidatorConfig)`

Copyright © 2021 JBoss by Red Hat. All rights reserved.