Interface Validator

All Known Implementing Classes:
ValidatorImpl

public interface Validator
Java Bean validation class. It offers the possibility to validate a given Java Bean against a set of defined constraints.
  • Method Summary

    Modifier and Type Method Description
    <K> Set<jakarta.validation.ConstraintViolation<Object>> getConstraintViolations​(K k)
    Checks if an object is valid and returns the list of the constraints not met.
    <K> List<String> getConstraintViolationsMessages​(K k)
    Checks if an object is valid and returns the list of the constraints messages not met.
    static <T> void notNull​(T object)
    Validate that the specified argument is not null; otherwise throws an IllegalArgumentException.
    static <T> void notNull​(T object, String message)
    Validate that the specified argument is not null; otherwise throws an IllegalArgumentException with the specified message.
    <K> void validate​(K k)
    Checks if an object is valid.
  • Method Details

    • getConstraintViolations

      <K> Set<jakarta.validation.ConstraintViolation<Object>> getConstraintViolations​(K k)
      Checks if an object is valid and returns the list of the constraints not met.
      Type Parameters:
      K - the object class
      Parameters:
      k - the object to check
      Returns:
      the list of violated constraints.
    • getConstraintViolationsMessages

      <K> List<String> getConstraintViolationsMessages​(K k)
      Checks if an object is valid and returns the list of the constraints messages not met.
      Type Parameters:
      K - the object class
      Parameters:
      k - the object to check
      Returns:
      the list of violated constraints messages.
    • validate

      <K> void validate​(K k)
      Checks if an object is valid.
      Type Parameters:
      K - the object class
      Parameters:
      k - the object to check
      Throws:
      InvalidBeanException - InvalidBeanException if the validation fails
    • notNull

      static <T> void notNull​(T object)
      Validate that the specified argument is not null; otherwise throws an IllegalArgumentException.
      Type Parameters:
      T - the object type
      Parameters:
      object - the object to check
      Throws:
      IllegalArgumentException - if the object is null
    • notNull

      static <T> void notNull​(T object, String message)
      Validate that the specified argument is not null; otherwise throws an IllegalArgumentException with the specified message.
      Type Parameters:
      T - the object type
      Parameters:
      object - the object to check
      message - the String.format(String, Object...) exception message if invalid, not null
      Throws:
      IllegalArgumentException - if the object is null