[
http://opensource.atlassian.com/projects/hibernate/browse/BVAL-208?page=c...
]
Arthur Ronald F D Garcia commented on BVAL-208:
-----------------------------------------------
Here goes some examples
Spring MVC 3.0, for instance, supports JSR-303 by using @Valid as ElementType.PARAMETER
public void doSomething(@Valid Command command, BindingResult result) throws Exception {}
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
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
}
}
So instead of (Not supported)
public void doSomething((a)Valid(groups=SomeUseCase.class) Command command,
BindingResult result) throws Exception {}
I need to use (old-style)
private CommandValidator validator = new CommandValidator();
public void doSomething(Command command, BindingResult result) throws Exception {
validator.validate(command, result);
}
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
public class Command {
@Valid
public Children getChildren() { return this.children; }
}
best regards
Arthur Ronald F D Garcia
@Valid should support groups attribute
--------------------------------------
Key: BVAL-208
URL:
http://opensource.atlassian.com/projects/hibernate/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.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira