Package 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 Description static ValidationResult
OK
An empty ValidationResult that's valid by default.
-
Constructor Summary
Constructors Constructor Description ValidationResult(Set<ValidationError> errors)
Creates a newValidationResult
from the given errors.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
forEachError(Consumer<ValidationError> consumer)
Convenience method that accepts aConsumer
.Set<ValidationError>
getErrors()
Set<ValidationError>
getErrorsForInputHint(String inputHint)
Returns aSet
ofValidationError's
with the giveninputHint
if present, otherwise an emptySet
is returned.Set<ValidationError>
getErrorsForValidatorId(String id)
Returns aSet
ofValidationError's
from theValidator
with the givenid
if present, otherwise an emptySet
is returned.boolean
hasErrorsForInputHint(String inputHint)
boolean
hasErrorsForValidatorId(String id)
void
ifNotValidAccept(Consumer<ValidationResult> consumer)
Convenience method that accepts aConsumer
if the result is not valid.boolean
isValid()
-
-
-
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 newValidationResult
from the given errors.The created
ValidationResult
is considered valid if the givenerrors
are empty.- Parameters:
errors
-
-
-
Method Detail
-
ifNotValidAccept
public void ifNotValidAccept(Consumer<ValidationResult> consumer)
Convenience method that accepts aConsumer
if the result is not valid.- Parameters:
consumer
-
-
forEachError
public void forEachError(Consumer<ValidationError> consumer)
Convenience method that accepts aConsumer
.- Parameters:
consumer
-
-
isValid
public boolean isValid()
-
getErrors
public Set<ValidationError> getErrors()
-
hasErrorsForValidatorId
public boolean hasErrorsForValidatorId(String id)
- Parameters:
id
-- Returns:
-
getErrorsForValidatorId
public Set<ValidationError> getErrorsForValidatorId(String id)
Returns aSet
ofValidationError's
from theValidator
with the givenid
if present, otherwise an emptySet
is returned.- Parameters:
id
-- Returns:
-
hasErrorsForInputHint
public boolean hasErrorsForInputHint(String inputHint)
Checks if thisValidationResult
containsValidationError's
with the giveninputHint
.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 aSet
ofValidationError's
with the giveninputHint
if present, otherwise an emptySet
is returned.- Parameters:
inputHint
-- Returns:
-
-