[hibernate-issues] [Hibernate-JIRA] Commented: (BVAL-244) Extend Validator API with methods for method validation

Gunnar Morling (JIRA) noreply at atlassian.com
Sun Sep 25 06:38:35 EDT 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/BVAL-244?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43682#comment-43682 ] 

Gunnar Morling commented on BVAL-244:
-------------------------------------

Proposal based on what there currently is implemented in HV:

* Extend {{javax.validation.Validator}} (can safely be done as not intended to be implemented by clients):

{code}
public interface Validator {

  //existing methods ...

  <T> Set<MethodConstraintViolation<T>> validateParameter(T object, Method method, Object parameterValue, int parameterIndex, Class<?>... groups);

  <T> Set<MethodConstraintViolation<T>> validateAllParameters(T object, Method method, Object[] parameterValues, Class<?>... groups);

  <T> Set<MethodConstraintViolation<T>> validateParameter(T object, Constructor constructor, Object parameterValue, int parameterIndex, Class<?>... groups);

  <T> Set<MethodConstraintViolation<T>> validateAllParameters(T object, Constructor constructor, Object[] parameterValues, Class<?>... groups);

  <T> Set<MethodConstraintViolation<T>> validateReturnValue(T object, Method method, Object returnValue, Class<?>... groups);

}
{code}

* Create new type {{javax.validation.MethodConstraintViolation}}:

{code}
public interface MethodConstraintViolation<T> extends ConstraintViolation<T> {

  public static enum Kind {

    PARAMETER,

    RETURN_VALUE
  }

  Method getMethod();

  Integer getParameterIndex();

  String getParameterName();

  Kind getKind();
}
{code}

* Create new type {{javax.validation.MethodConstraintViolationException}} to be thrown by integrators of the method validation feature:

{code}
public class MethodConstraintViolationException extends ValidationException {

  private final Set<MethodConstraintViolation<?>> constraintViolations;

  //constructor ...

  public Set<MethodConstraintViolation<?>> getConstraintViolations() {
    return constraintViolations;
  }
}
{code}

> Extend Validator API with methods for method validation
> -------------------------------------------------------
>
>                 Key: BVAL-244
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/BVAL-244
>             Project: Bean Validation
>          Issue Type: Sub-task
>          Components: spec-general
>            Reporter: Gunnar Morling
>             Fix For: 1.1
>
>
> {{javax.validation.Validator}} needs additional methods for method validation.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list