Class ValidationResult
java.lang.Object
tech.guilhermekaua.spigotboot.core.validation.ValidationResult
Result of validating an object.
-
Method Summary
Modifier and TypeMethodDescription@NotNull List<ValidationError>errors()Gets all validation errors.@NotNull StringFormats all errors for display.@NotNull StringformatErrors(@NotNull String prefix) Formats all errors with a prefix.@NotNull List<ValidationError>Gets only errors marked as fail-fast.booleanChecks if there are any errors.booleanisValid()Checks if the validation passed (no errors).@NotNull ValidationResultmerge(@NotNull ValidationResult other) Merges this result with another.static @NotNull ValidationResultof(@NotNull List<ValidationError> errors) Creates a result with the given errors.static @NotNull ValidationResultof(@NotNull ValidationError error) Creates a result with a single error.toString()static @NotNull ValidationResultvalid()Creates a valid result with no errors.
-
Method Details
-
valid
Creates a valid result with no errors.- Returns:
- a valid result
-
of
Creates a result with the given errors.- Parameters:
errors- the errors- Returns:
- a result with errors
-
of
Creates a result with a single error.- Parameters:
error- the error- Returns:
- a result with the error
-
isValid
public boolean isValid()Checks if the validation passed (no errors).- Returns:
- true if valid
-
hasErrors
public boolean hasErrors()Checks if there are any errors.- Returns:
- true if there are errors
-
errors
Gets all validation errors.- Returns:
- the list of errors
-
getFailFastErrors
Gets only errors marked as fail-fast.- Returns:
- the list of fail-fast errors
-
formatErrors
Formats all errors for display.- Returns:
- the formatted errors
-
formatErrors
Formats all errors with a prefix.- Parameters:
prefix- the prefix for each line- Returns:
- the formatted errors
-
merge
Merges this result with another.- Parameters:
other- the other result- Returns:
- a merged result
-
toString
-