org.keycloak.validate

## Class ValidationContext

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

- Direct Known Subclasses:
    UserProfileAttributeValidationContext

      public class ValidationContext
      extends Object

  Holds information about the validation state.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `` | `ValidationContext()` Creates a new `ValidationContext` without a `KeycloakSession`.
    `` | `ValidationContext(KeycloakSession session)` Creates a new `ValidationContext` with a `KeycloakSession`.
    `protected` | `ValidationContext(KeycloakSession session, Set<ValidationError> errors)` Creates a new `ValidationContext`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addError(ValidationError error)` Adds an `ValidationError`.
    `Map<String,Object>` | `getAttributes()`
    `Set<ValidationError>` | `getErrors()`
    `KeycloakSession` | `getSession()`
    `boolean` | `isValid()` Convenience method for checking the validation status of the current `ValidationContext`.
    `ValidationResult` | `toResult()` Creates a `ValidationResult` based on the current errors;
    `String` | `toString()`
    `Validator` | `validator(String validatorId)` Eases access to `Validator's` for nested validation.

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

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

- - ### Constructor Detail

    - #### ValidationContext

          public ValidationContext()

      Creates a new `ValidationContext` without a `KeycloakSession`.

    - #### ValidationContext

          public ValidationContext(KeycloakSession session)

      Creates a new `ValidationContext` with a `KeycloakSession`.
      Parameters:
        `session` -

    - #### ValidationContext

          protected ValidationContext(KeycloakSession session,
                                      Set<ValidationError> errors)

      Creates a new `ValidationContext`.
      Parameters:
        `session` -
        `errors` -

  - ### Method Detail

    - #### validator

          public Validator validator(String validatorId)

      Eases access to `Validator's` for nested validation.
      Parameters:
        `validatorId` -
      Returns:

    - #### addError

          public void addError(ValidationError error)

      Adds an `ValidationError`.
      Parameters:
        `error` -

    - #### isValid

          public boolean isValid()

      Convenience method for checking the validation status of the current `ValidationContext`.

      This is an alternative to `toResult().isValid()` for brief validations.

      Returns:

    - #### getAttributes

          public Map<String,Object> getAttributes()

    - #### getSession

          public KeycloakSession getSession()

    - #### getErrors

          public Set<ValidationError> getErrors()

    - #### toResult

          public ValidationResult toResult()

      Creates a `ValidationResult` based on the current errors;
      Returns:

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

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