Class ValidationResult

java.lang.Object
tech.guilhermekaua.spigotboot.core.validation.ValidationResult

public final class ValidationResult extends Object
Result of validating an object.
  • Method Details

    • valid

      @NotNull public static @NotNull ValidationResult valid()
      Creates a valid result with no errors.
      Returns:
      a valid result
    • of

      @NotNull public static @NotNull ValidationResult of(@NotNull @NotNull List<ValidationError> errors)
      Creates a result with the given errors.
      Parameters:
      errors - the errors
      Returns:
      a result with errors
    • of

      @NotNull public static @NotNull ValidationResult of(@NotNull @NotNull ValidationError error)
      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

      @NotNull public @NotNull List<ValidationError> errors()
      Gets all validation errors.
      Returns:
      the list of errors
    • getFailFastErrors

      @NotNull public @NotNull List<ValidationError> getFailFastErrors()
      Gets only errors marked as fail-fast.
      Returns:
      the list of fail-fast errors
    • formatErrors

      @NotNull public @NotNull String formatErrors()
      Formats all errors for display.
      Returns:
      the formatted errors
    • formatErrors

      @NotNull public @NotNull String formatErrors(@NotNull @NotNull String prefix)
      Formats all errors with a prefix.
      Parameters:
      prefix - the prefix for each line
      Returns:
      the formatted errors
    • merge

      @NotNull public @NotNull ValidationResult merge(@NotNull @NotNull ValidationResult other)
      Merges this result with another.
      Parameters:
      other - the other result
      Returns:
      a merged result
    • toString

      public String toString()
      Overrides:
      toString in class Object