22
33import com .fasterxml .jackson .databind .JsonNode ;
44import com .networknt .schema .i18n .MessageSource ;
5- import com .networknt .schema .utils .StringUtils ;
65
76import java .util .Collections ;
87import java .util .LinkedHashMap ;
@@ -26,7 +25,7 @@ public abstract class ValidationMessageHandler {
2625 protected ValidationMessageHandler (ErrorMessageType errorMessageType , String errorMessageKeyword ,
2726 MessageSource messageSource , Keyword keyword , JsonSchema parentSchema , SchemaLocation schemaLocation ,
2827 JsonNodePath evaluationPath ) {
29- ErrorMessageType currentErrorMessageType = errorMessageType ;
28+ this . errorMessageType = errorMessageType ;
3029 this .messageSource = messageSource ;
3130 this .schemaLocation = Objects .requireNonNull (schemaLocation );
3231 this .evaluationPath = Objects .requireNonNull (evaluationPath );
@@ -36,24 +35,12 @@ protected ValidationMessageHandler(ErrorMessageType errorMessageType, String err
3635 this .keyword = keyword ;
3736
3837 Map <String , String > currentErrorMessage = null ;
39-
4038 if (this .keyword != null ) {
4139 if (this .errorMessageKeyword != null && keyword != null && parentSchema != null ) {
4240 currentErrorMessage = getErrorMessage (this .errorMessageKeyword , parentSchema .getSchemaNode (),
4341 keyword .getValue ());
4442 }
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- }
5543 }
56- this .errorMessageType = currentErrorMessageType ;
5744 this .errorMessage = currentErrorMessage ;
5845 }
5946
@@ -143,11 +130,4 @@ protected JsonNode getMessageNode(String errorMessageKeyword, JsonNode schemaNod
143130 }
144131 return messageNode ;
145132 }
146-
147- protected String getErrorCodeKey (String keyword ) {
148- if (keyword != null ) {
149- return keyword + "ErrorCode" ;
150- }
151- return null ;
152- }
153133}
0 commit comments