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 ValidationResultOKAn empty ValidationResult that's valid by default.
-
Constructor Summary
Constructors Constructor Description ValidationResult(Set<ValidationError> errors)Creates a newValidationResultfrom the given errors.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidforEachError(Consumer<ValidationError> consumer)Convenience method that accepts aConsumer.Set<ValidationError>getErrors()Set<ValidationError>getErrorsForInputHint(String inputHint)Returns aSetofValidationError'swith the giveninputHintif present, otherwise an emptySetis returned.Set<ValidationError>getErrorsForValidatorId(String id)Returns aSetofValidationError'sfrom theValidatorwith the givenidif present, otherwise an emptySetis returned.booleanhasErrorsForInputHint(String inputHint)booleanhasErrorsForValidatorId(String id)voidifNotValidAccept(Consumer<ValidationResult> consumer)Convenience method that accepts aConsumerif the result is not valid.booleanisValid()
-
-
-
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 newValidationResultfrom the given errors.The created
ValidationResultis considered valid if the givenerrorsare empty.- Parameters:
errors-
-
-
Method Detail
-
ifNotValidAccept
public void ifNotValidAccept(Consumer<ValidationResult> consumer)
Convenience method that accepts aConsumerif 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 aSetofValidationError'sfrom theValidatorwith the givenidif present, otherwise an emptySetis returned.- Parameters:
id-- Returns:
-
hasErrorsForInputHint
public boolean hasErrorsForInputHint(String inputHint)
Checks if thisValidationResultcontainsValidationError'swith the giveninputHint.This can be used to test if there are
ValidationError'sfor a specified attribute or attribute path.- Parameters:
inputHint-- Returns:
-
getErrorsForInputHint
public Set<ValidationError> getErrorsForInputHint(String inputHint)
Returns aSetofValidationError'swith the giveninputHintif present, otherwise an emptySetis returned.- Parameters:
inputHint-- Returns:
-
-