[hibernate-issues] [Hibernate-JIRA] Issue Comment Edited: (BVAL-208) support groups translation when cascading operations (hosted on @Valid or not)

Hardy Ferentschik (JIRA) noreply at atlassian.com
Tue Apr 3 09:11:48 EDT 2012


    [ https://hibernate.onjira.com/browse/BVAL-208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=38181#comment-38181 ] 

Hardy Ferentschik edited comment on BVAL-208 at 4/3/12 8:11 AM:
----------------------------------------------------------------

Here goes some examples

Spring MVC 3.0, for instance, supports JSR-303 by using @Valid as ElementType.PARAMETER
{code}
public void doSomething(@Valid Command command, BindingResult result) throws Exception {}
{code}
But if JSR-303 supports the concept of groups, how can i supply which group i want to test. Because of that, i need to implement a Spring Validator interface instead
{code}
    public class CommandValidator implements Validator {
        public bollean supports(Class clazz) {}

        public void validate(Object command, Errors errors) {
            Set<ConstraintViolation<Command>> constraintViolationSet = ValidatorUtil.getValidator().validate((Command) command, SomeUseCase.class);
            // post-proccessing validation
        }
    }
{code}

So instead of (Not supported)
{code}
    public void doSomething(@Valid(groups=SomeUseCase.class) Command command, BindingResult result) throws Exception {}   
{code}
I need to use (old-style)
{code}
    private CommandValidator validator = new CommandValidator();

    public void doSomething(Command command, BindingResult result) throws Exception {
        validator.validate(command, result);
    }
{code}
There is more As @Valid annotation fullfil nested properties, how can i supply which group of the nested property i want to test ??? As @Valid does not support groups attribute, i just can use @Valid when using default group. Otherwise, i need to remove it
{code}
    public class Command {
        @Valid
        public Children getChildren() { return this.children; }
    }
{code}
best regards

Arthur Ronald F D Garcia

      was (Author: alpha88):
    Here goes some examples

Spring MVC 3.0, for instance, supports JSR-303 by using @Valid as ElementType.PARAMETER
{code}
public void doSomething(@Valid Command command, BindingResult result) throws Exception {}
{code}
But if JSR-303 supports the concept of groups, how can i supply which group i want to test. Because of that, i need to implement a Spring Validator interface instead
{code}
    public class CommandValidator implements Validator {

        public bollean supports(Class clazz) {}

        public void validate(Object command, Errors errors) {
            Set<ConstraintViolation<Command>> constraintViolationSet = ValidatorUtil.getValidator().validate((Command) command, SomeUseCase.class);


            // post-proccessing validation

        }

    }
{code}

So instead of (Not supported)
{code}
    public void doSomething(@Valid(groups=SomeUseCase.class) Command command, BindingResult result) throws Exception {}   
{code}
I need to use (old-style)
{code}
    private CommandValidator validator = new CommandValidator();

    public void doSomething(Command command, BindingResult result) throws Exception {
        validator.validate(command, result);
    }
{code}
There is more As @Valid annotation fullfil nested properties, how can i supply which group of the nested property i want to test ??? As @Valid does not support groups attribute, i just can use @Valid when using default group. Otherwise, i need to remove it
{code}
    public class Command {

        @Valid
        public Children getChildren() { return this.children; }

    }
{code}
best regards

Arthur Ronald F D Garcia
  
> support groups translation when cascading operations (hosted on @Valid or not)
> ------------------------------------------------------------------------------
>
>                 Key: BVAL-208
>                 URL: https://hibernate.onjira.com/browse/BVAL-208
>             Project: Bean Validation
>          Issue Type: Improvement
>    Affects Versions: 1.0 final
>            Reporter: Marc Schipperheyn
>
> The @Valid annotation should implement the group attribute in order to make validation completely annotation driven. Currently, we need to manually call the validate method on the validator if we want to validate based on groups.

--
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