javax.validation

Interface Validator


  • public interface Validator
    Validates bean instances. Implementations of this interface must be thread-safe.
    Author:
    Emmanuel Bernard, Hardy Ferentschik, Gunnar Morling
    • Method Detail

      • validate

        <T> Set<ConstraintViolation<T>> validate(T object,
                                                 Class<?>... groups)
        Validates all constraints on object.
        Parameters:
        object - object to validate
        groups - the group or list of groups targeted for validation (defaults to Default)
        Returns:
        constraint violations or an empty set if none
        Throws:
        IllegalArgumentException - if object is null or if null is passed to the varargs groups
        ValidationException - if a non recoverable error happens during the validation process
      • validateProperty

        <T> Set<ConstraintViolation<T>> validateProperty(T object,
                                                         String propertyName,
                                                         Class<?>... groups)
        Validates all constraints placed on the property of object named propertyName.
        Parameters:
        object - object to validate
        propertyName - property to validate (i.e. field and getter constraints)
        groups - the group or list of groups targeted for validation (defaults to Default)
        Returns:
        constraint violations or an empty set if none
        Throws:
        IllegalArgumentException - if object is null, if propertyName is null, empty or not a valid object property or if null is passed to the varargs groups
        ValidationException - if a non recoverable error happens during the validation process
      • getConstraintsForClass

        BeanDescriptor getConstraintsForClass(Class<?> clazz)
        Returns the descriptor object describing bean constraints.

        The returned object (and associated objects including ConstraintDescriptors) are immutable.

        Parameters:
        clazz - class or interface type evaluated
        Returns:
        the bean descriptor for the specified class
        Throws:
        IllegalArgumentException - if clazz is null
        ValidationException - if a non recoverable error happens during the metadata discovery or if some constraints are invalid.
      • unwrap

        <T> T unwrap(Class<T> type)
        Returns an instance of the specified type allowing access to provider-specific APIs.

        If the Bean Validation provider implementation does not support the specified class, ValidationException is thrown.

        Parameters:
        type - the class of the object to be returned
        Returns:
        an instance of the specified class
        Throws:
        ValidationException - if the provider does not support the call
      • forExecutables

        ExecutableValidator forExecutables()
        Returns the contract for validating parameters and return values of methods and constructors.
        Returns:
        contract for method and constructor validation
        Since:
        1.1

Traduction non disponible

Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.

Version en cache

21/08/2025 14:26:55 Cette version de la page est en cache (à la date du 21/08/2025 14:26:55) afin d'accélérer le traitement.
Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.

Document créé le 11/06/2005, dernière modification le 18/08/2025
Source du document imprimé : https://www.gaudry.be/java-api-javaee-rf-javax/validation/Validator.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.

Références

  1. Consulter le document html Langue du document :fr Manuel PHP : https://docs.oracle.com, Validator (Java(TM) EE 7 Specification APIs)

Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.