Class ValidationErrors

java.lang.Object
su.onno.validation.ValidationErrors

public final class ValidationErrors extends Object
Accumulates validation failures across all sources (declarative attribute constraints, custom BusinessRules) so the user sees every problem at once rather than one at a time. throwIfAny() raises a ValidationException when anything was collected.
  • Constructor Details

    • ValidationErrors

      public ValidationErrors()
  • Method Details

    • field

      public void field(String field, String message)
      Record a message on a field; a null/blank field falls back to a form-level message.
    • form

      public void form(String message)
      Record a cross-field / form-level message.
    • isEmpty

      public boolean isEmpty()
    • fieldErrors

      public Map<String,List<String>> fieldErrors()
      Everything collected per field so far, for callers that report without throwing.
    • formErrors

      public List<String> formErrors()
      Every form-level message collected so far, for callers that report without throwing.
    • throwIfAny

      public void throwIfAny()
      Throw a ValidationException carrying everything collected, if non-empty.