2
2
3
3
import com .fasterxml .jackson .databind .JsonNode ;
4
4
import com .networknt .schema .i18n .MessageSource ;
5
- import com .networknt .schema .utils .StringUtils ;
6
5
7
6
import java .util .Collections ;
8
7
import java .util .LinkedHashMap ;
@@ -26,7 +25,7 @@ public abstract class ValidationMessageHandler {
26
25
protected ValidationMessageHandler (ErrorMessageType errorMessageType , String errorMessageKeyword ,
27
26
MessageSource messageSource , Keyword keyword , JsonSchema parentSchema , SchemaLocation schemaLocation ,
28
27
JsonNodePath evaluationPath ) {
29
- ErrorMessageType currentErrorMessageType = errorMessageType ;
28
+ this . errorMessageType = errorMessageType ;
30
29
this .messageSource = messageSource ;
31
30
this .schemaLocation = Objects .requireNonNull (schemaLocation );
32
31
this .evaluationPath = Objects .requireNonNull (evaluationPath );
@@ -36,24 +35,12 @@ protected ValidationMessageHandler(ErrorMessageType errorMessageType, String err
36
35
this .keyword = keyword ;
37
36
38
37
Map <String , String > currentErrorMessage = null ;
39
-
40
38
if (this .keyword != null ) {
41
39
if (this .errorMessageKeyword != null && keyword != null && parentSchema != null ) {
42
40
currentErrorMessage = getErrorMessage (this .errorMessageKeyword , parentSchema .getSchemaNode (),
43
41
keyword .getValue ());
44
42
}
45
- String errorCodeKey = getErrorCodeKey (keyword .getValue ());
46
- if (errorCodeKey != null && this .parentSchema != null ) {
47
- JsonNode errorCodeNode = this .parentSchema .getSchemaNode ().get (errorCodeKey );
48
- if (errorCodeNode != null && errorCodeNode .isTextual ()) {
49
- String errorCodeText = errorCodeNode .asText ();
50
- if (StringUtils .isNotBlank (errorCodeText )) {
51
- currentErrorMessageType = CustomErrorMessageType .of (errorCodeText );
52
- }
53
- }
54
- }
55
43
}
56
- this .errorMessageType = currentErrorMessageType ;
57
44
this .errorMessage = currentErrorMessage ;
58
45
}
59
46
@@ -143,11 +130,4 @@ protected JsonNode getMessageNode(String errorMessageKeyword, JsonNode schemaNod
143
130
}
144
131
return messageNode ;
145
132
}
146
-
147
- protected String getErrorCodeKey (String keyword ) {
148
- if (keyword != null ) {
149
- return keyword + "ErrorCode" ;
150
- }
151
- return null ;
152
- }
153
133
}
0 commit comments