org.keycloak.validate

## Class ValidationResult

- java.lang.Object
- - org.keycloak.validate.ValidationResult

-     public class ValidationResult
      extends Object

  Denotes the result of a validation.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static ValidationResult` | `OK` An empty ValidationResult that's valid by default.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ValidationResult(Set<ValidationError> errors)` Creates a new `ValidationResult` from the given errors.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `forEachError(Consumer<ValidationError> consumer)` Convenience method that accepts a `Consumer`.
    `Set<ValidationError>` | `getErrors()`
    `Set<ValidationError>` | `getErrorsForInputHint(String inputHint)` Returns a `Set` of `ValidationError's` with the given `inputHint` if present, otherwise an empty `Set` is returned.
    `Set<ValidationError>` | `getErrorsForValidatorId(String id)` Returns a `Set` of `ValidationError's` from the `Validator` with the given `id` if present, otherwise an empty `Set` is returned.
    `boolean` | `hasErrorsForInputHint(String inputHint)` Checks if this `ValidationResult` contains `ValidationError's` with the given `inputHint`.
    `boolean` | `hasErrorsForValidatorId(String id)` Checks if this `ValidationResult` contains `ValidationError's` from the `Validator` with the given `id`.
    `void` | `ifNotValidAccept(Consumer<ValidationResult> consumer)` Convenience method that accepts a `Consumer` if the result is not valid.
    `boolean` | `isValid()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### OK

          public static final ValidationResult OK

      An empty ValidationResult that's valid by default.

  - ### Constructor Detail

    - #### ValidationResult

          public ValidationResult(Set<ValidationError> errors)

      Creates a new `ValidationResult` from the given errors.

      The created `ValidationResult` is considered valid if the given `errors` are empty.

      Parameters:
        `errors` -

  - ### Method Detail

    - #### ifNotValidAccept

          public void ifNotValidAccept(Consumer<ValidationResult> consumer)

      Convenience method that accepts a `Consumer` if the result is not valid.
      Parameters:
        `consumer` -

    - #### forEachError

          public void forEachError(Consumer<ValidationError> consumer)

      Convenience method that accepts a `Consumer`.
      Parameters:
        `consumer` -

    - #### isValid

          public boolean isValid()

    - #### getErrors

          public Set<ValidationError> getErrors()

    - #### hasErrorsForValidatorId

          public boolean hasErrorsForValidatorId(String id)

      Checks if this `ValidationResult` contains `ValidationError's` from the `Validator` with the given `id`.
      Parameters:
        `id` -
      Returns:

    - #### getErrorsForValidatorId

          public Set<ValidationError> getErrorsForValidatorId(String id)

      Returns a `Set` of `ValidationError's` from the `Validator` with the given `id` if present, otherwise an empty `Set` is returned.

      Parameters:
        `id` -
      Returns:

    - #### hasErrorsForInputHint

          public boolean hasErrorsForInputHint(String inputHint)

      Checks if this `ValidationResult` contains `ValidationError's` with the given `inputHint`.

      This can be used to test if there are `ValidationError's` for a specified attribute or attribute path.

      Parameters:
        `inputHint` -
      Returns:

    - #### getErrorsForInputHint

          public Set<ValidationError> getErrorsForInputHint(String inputHint)

      Returns a `Set` of `ValidationError's` with the given `inputHint` if present, otherwise an empty `Set` is returned.

      Parameters:
        `inputHint` -
      Returns:

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