08-02-2023, 01:30 PM
I have the following controller method:
@RequestMapping(value="/map/update", method=RequestMethod.POST, produces = "application/json; charset=utf-8")
@ResponseBody
public ResponseEntityWrapper updateMapTheme(
HttpServletRequest request,
@RequestBody @Valid List<CompanyTag> categories,
HttpServletResponse response
) throws ResourceNotFoundException, AuthorizationException {
...
}
CompanyTag is defined this way:
public class CompanyTag {
@StringUUIDValidation String key;
String value;
String color;
String icon;
Icon iconObj;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
...
}
The problem is that validation is not triggered, the CompanyTag list is not validated, the "StringUUIDValidation" validator is never called.
If I remove the List and only try to send a single CompanyTag, i.e. instead of:
@RequestBody @Valid List<CompanyTag> categories,
use:
@RequestBody @Valid CompanyTag category,
it works as expected, so apparently Spring does not like to validate lists of things (tried with array instead, that did not work either).
Anybody have any idea what's missing?
@RequestMapping(value="/map/update", method=RequestMethod.POST, produces = "application/json; charset=utf-8")
@ResponseBody
public ResponseEntityWrapper updateMapTheme(
HttpServletRequest request,
@RequestBody @Valid List<CompanyTag> categories,
HttpServletResponse response
) throws ResourceNotFoundException, AuthorizationException {
...
}
CompanyTag is defined this way:
public class CompanyTag {
@StringUUIDValidation String key;
String value;
String color;
String icon;
Icon iconObj;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
...
}
The problem is that validation is not triggered, the CompanyTag list is not validated, the "StringUUIDValidation" validator is never called.
If I remove the List and only try to send a single CompanyTag, i.e. instead of:
@RequestBody @Valid List<CompanyTag> categories,
use:
@RequestBody @Valid CompanyTag category,
it works as expected, so apparently Spring does not like to validate lists of things (tried with array instead, that did not work either).
Anybody have any idea what's missing?