Reputation: 7468
I have following in my method definition:
@RequestParam Map<String, Object> queryMap
I have to validate the values in Map. Are there any spring provided means or assert is the best practice for it?
Upvotes: 0
Views: 652
Reputation: 756
General validation protocol for @RequestParam
:
@RequestParam("number") @Min(5) @Max(10) int number
If you need to validate Map
values, you may have to write certain custom validations.
Upvotes: 2
Reputation: 915
There is JSR-303
standard about validation.
Use @Valid
annotation.
Example code:
@RequestMapping(value = "/appointments", method = RequestMethod.POST)
public String add(@Valid AppointmentForm form, BindingResult result) {
....
}
static class AppointmentForm {
@NotNull
private Date date;
}
Upvotes: 0