I tried the approach mentioned on How get property name in a validation message, but cannot apply it to the following situation.
@Data
public class CompanyRequest {
@PositiveOrZero(message = "validation.amount.positiveOrZero")
int quantity;
// code omitted for brevity
}
Here is my *.properties
file having message:
validation.amount.positiveOrZero=The ${fieldName} value must be positive or zero
So, how can I use the property name in the validation message?