Skip to content

Commit

Permalink
Ensure getField(String) wildcard support with SF 6.1+
Browse files Browse the repository at this point in the history
Closes gh-1814
  • Loading branch information
rstoyanchev committed Oct 10, 2024
1 parent 6b5200f commit 6151be4
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2012 the original author or authors.
* Copyright 2004-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,6 +37,7 @@
import org.springframework.binding.message.MessageCriteria;
import org.springframework.binding.message.Severity;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.validation.AbstractErrors;
import org.springframework.validation.BindingResult;
Expand Down Expand Up @@ -127,6 +128,12 @@ public List<FieldError> getFieldErrors(String field) {
return toErrors(messageContext.getMessagesByCriteria(messageCriteria), FIELD_ERRORS);
}

// Override to ensure use of overridden getFieldErrors(String)
public FieldError getFieldError(String field) {
List<FieldError> fieldErrors = getFieldErrors(field);
return (!fieldErrors.isEmpty() ? fieldErrors.get(0) : null);
}

public Class<?> getFieldType(String field) {
return parseFieldExpression(fixedField(field), false).getValueType(boundObject);
}
Expand Down

0 comments on commit 6151be4

Please sign in to comment.