org.keycloak.validate.validators

## Class DoubleValidator

- java.lang.Object
- - org.keycloak.validate.AbstractSimpleValidator
  - - org.keycloak.validate.validators.AbstractNumberValidator
    - - org.keycloak.validate.validators.DoubleValidator

- All Implemented Interfaces:
    ConfiguredProvider, Provider, ProviderFactory<Validator>, SimpleValidator, Validator, ValidatorFactory

      public class DoubleValidator
      extends AbstractNumberValidator
      implements ConfiguredProvider

  Validate input being any kind of `Number`. Accepts String also if convertible to `Double` by common `Double.parseDouble(String)`. Min and Max validation is based on `Double` precision also.
  Author:
    Vlastimil Elias

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `ID`
    `static DoubleValidator` | `INSTANCE`

    - ### Fields inherited from class org.keycloak.validate.validators.AbstractNumberValidator

      `configProperties, KEY_MAX, KEY_MIN, MESSAGE_INVALID_NUMBER, MESSAGE_NUMBER_OUT_OF_RANGE`

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

      `IGNORE_EMPTY_VALUE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DoubleValidator()`
    `DoubleValidator(ValidatorConfig config)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and 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 validator
    `protected boolean` | `isFirstGreaterThanToSecond(Number n1, Number n2)` Compare two numbers of supported type (fed by `AbstractNumberValidator.convert(Object, ValidatorConfig)` and `AbstractNumberValidator.getMinMaxConfig(ValidatorConfig, String)` )

    - ### Methods inherited from class org.keycloak.validate.validators.AbstractNumberValidator

      `doValidate, getConfigProperties, 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

      `getConfigProperties`

    - ### 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.provider.ProviderFactory

      `order`

- - ### Field Detail

    - #### ID

          public static final String ID

      See Also:
        Constant Field Values

    - #### INSTANCE

          public static final DoubleValidator INSTANCE

  - ### Constructor Detail

    - #### DoubleValidator

          public DoubleValidator()

    - #### DoubleValidator

          public DoubleValidator(ValidatorConfig config)

  - ### Method Detail

    - #### getId

          public String getId()

      Specified by:
        `getId` in interface `ProviderFactory<Validator>`

    - #### 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 class `AbstractNumberValidator`
      Parameters:
        `value` - to convert
      Returns:
        value converted to supported Number instance

    - #### 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 class `AbstractNumberValidator`
      Parameters:
        `config` - to get from
        `key` - 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 by `AbstractNumberValidator.convert(Object, ValidatorConfig)` and `AbstractNumberValidator.getMinMaxConfig(ValidatorConfig, String)` )
      Specified by:
        `isFirstGreaterThanToSecond` in class `AbstractNumberValidator`
      Returns:
        true if first number is greater than second

    - #### getHelpText

          public String getHelpText()

      Specified by:
        `getHelpText` in interface `ConfiguredProvider`

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