Skip to content

Commit fdc40d9

Browse files
committed
Added a temporary fix for field name mapping
1 parent 28b4ba3 commit fdc40d9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main/java/org/javawebstack/validator/Validator.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,13 @@ private static <V> V getMapValue(Map<String[], V> map, String[] key){
221221
return null;
222222
}
223223

224+
private static String getFieldName(Field field){
225+
SerializedName[] serializedNames = field.getAnnotationsByType(SerializedName.class);
226+
if(serializedNames.length > 0)
227+
return serializedNames[0].value();
228+
return field.getName();
229+
}
230+
224231
private static Map<String[], List<ValidationRule>> getClassRules(Class<?> type){
225232
Map<String[], List<ValidationRule>> rules = new HashMap<>();
226233
if(type.isAnnotation())
@@ -257,7 +264,7 @@ private static Map<String[], List<ValidationRule>> getClassRules(Class<?> type){
257264
return rules;
258265
}
259266
for(Field field : getFieldsRecursive(type)){
260-
String name = FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES.translateName(field);
267+
String name = getFieldName(field);
261268
getClassRules(field.getType()).forEach((key, validators) -> {
262269
String[] actualKey = new String[key.length+1];
263270
actualKey[0] = name;

0 commit comments

Comments
 (0)