Class ValidationUtil

java.lang.Object
org.dellroad.stuff.validation.ValidationUtil

public final class ValidationUtil extends Object
Validation utility methods.
  • Method Details

    • validate

      public static <T> Set<jakarta.validation.ConstraintViolation<T>> validate(T obj, Class<?>... groups)
      Validate the given object.

      This method simply creates a ValidationContext with the given root and invokes ValidationContext.validate().

      Type Parameters:
      T - root validation object type
      Parameters:
      obj - object to validate
      groups - group(s) targeted for validation (if empty, defaults to Default)
      Returns:
      zero or more violations
      Throws:
      IllegalArgumentException - if either paramter is null
    • describe

      public static String describe(Set<? extends jakarta.validation.ConstraintViolation<?>> violations)
      Describe the validation errors in a friendly format.
      Parameters:
      violations - validation violations
      Returns:
      description of the validation errors
      Throws:
      NullPointerException - if violations is null