Skip to content

Commit

Permalink
added special handling of String array values for required fields, e.…
Browse files Browse the repository at this point in the history
…g. for WebRequestDataBinder (SPR-6552)
  • Loading branch information
jhoeller committed Dec 14, 2009
1 parent 26b3443 commit 8647559
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,17 @@ protected void checkRequiredFields(MutablePropertyValues mpvs) {
}
for (String field : requiredFields) {
PropertyValue pv = propertyValues.get(field);
if (pv == null || pv.getValue() == null ||
(pv.getValue() instanceof String && !StringUtils.hasText((String) pv.getValue()))) {
boolean empty = (pv == null || pv.getValue() == null);
if (!empty) {
if (pv.getValue() instanceof String) {
empty = !StringUtils.hasText((String) pv.getValue());
}
else if (pv.getValue() instanceof String[]) {
String[] values = (String[]) pv.getValue();
empty = (values.length == 0 || !StringUtils.hasText(values[0]));
}
}
if (empty) {
// Use bind error processor to create FieldError.
getBindingErrorProcessor().processMissingFieldError(field, getInternalBindingResult());
// Remove property from property values to bind:
Expand Down

0 comments on commit 8647559

Please sign in to comment.