Package 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 Description ValidationContext()
Creates a newValidationContext
without aKeycloakSession
.ValidationContext(KeycloakSession session)
Creates a newValidationContext
with aKeycloakSession
.protected
ValidationContext(KeycloakSession session, Set<ValidationError> errors)
Creates a newValidationContext
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addError(ValidationError error)
Adds anValidationError
.Map<String,Object>
getAttributes()
Set<ValidationError>
getErrors()
KeycloakSession
getSession()
boolean
isValid()
Convenience method for checking the validation status of the currentValidationContext
.ValidationResult
toResult()
Creates aValidationResult
based on the current errors;String
toString()
Validator
validator(String validatorId)
Eases access toValidator's
for nested validation.
-
-
-
Constructor Detail
-
ValidationContext
public ValidationContext()
Creates a newValidationContext
without aKeycloakSession
.
-
ValidationContext
public ValidationContext(KeycloakSession session)
Creates a newValidationContext
with aKeycloakSession
.- Parameters:
session
-
-
ValidationContext
protected ValidationContext(KeycloakSession session, Set<ValidationError> errors)
Creates a newValidationContext
.- Parameters:
session
-errors
-
-
-
Method Detail
-
validator
public Validator validator(String validatorId)
Eases access toValidator's
for nested validation.- Parameters:
validatorId
-- Returns:
-
addError
public void addError(ValidationError error)
Adds anValidationError
.- Parameters:
error
-
-
isValid
public boolean isValid()
Convenience method for checking the validation status of the currentValidationContext
.This is an alternative to
toResult().isValid()
for brief validations.- Returns:
-
getSession
public KeycloakSession getSession()
-
getErrors
public Set<ValidationError> getErrors()
-
toResult
public ValidationResult toResult()
Creates aValidationResult
based on the current errors;- Returns:
-
-