There are three very simple steps involved:
- Ensure that your newly written, fully tested constraint is on your web-app’s classpath
- Annotate your bean with your constraint:
public class JSRValidatedAddress {
@BirminghamPostCode(message = "This must be a Birmingham post code")
private String postCode;
// Reset of the code ommited for clarity - Use the @Valid annotation to mark your bean for validation
etc.@RequestMapping(value = PATH, method = RequestMethod.POST)
public String addAddress(@Valid JSRValidatedAddress address, BindingResult result,
Model model) {
No comments:
Post a comment