@@ -26,6 +26,7 @@ public class ValidationMessage {
2626 private String type ;
2727 private String code ;
2828 private String path ;
29+ private String schemaPath ;
2930 private String [] arguments ;
3031 private Map <String , Object > details ;
3132 private String message ;
@@ -41,6 +42,9 @@ void setCode(String code) {
4142 this .code = code ;
4243 }
4344
45+ /**
46+ * @return The path to the input json
47+ */
4448 public String getPath () {
4549 return path ;
4650 }
@@ -49,6 +53,17 @@ void setPath(String path) {
4953 this .path = path ;
5054 }
5155
56+ /**
57+ * @return The path to the schema
58+ */
59+ public String getSchemaPath () {
60+ return schemaPath ;
61+ }
62+
63+ public void setSchemaPath (String schemaPath ) {
64+ this .schemaPath = schemaPath ;
65+ }
66+
5267 public String [] getArguments () {
5368 return arguments ;
5469 }
@@ -88,6 +103,7 @@ public boolean equals(Object o) {
88103 if (type != null ? !type .equals (that .type ) : that .type != null ) return false ;
89104 if (code != null ? !code .equals (that .code ) : that .code != null ) return false ;
90105 if (path != null ? !path .equals (that .path ) : that .path != null ) return false ;
106+ if (schemaPath != null ? !schemaPath .equals (that .schemaPath ) : that .schemaPath != null ) return false ;
91107 if (details != null ? !details .equals (that .details ) : that .details != null ) return false ;
92108 if (!Arrays .equals (arguments , that .arguments )) return false ;
93109 return !(message != null ? !message .equals (that .message ) : that .message != null );
@@ -99,6 +115,7 @@ public int hashCode() {
99115 int result = type != null ? type .hashCode () : 0 ;
100116 result = 31 * result + (code != null ? code .hashCode () : 0 );
101117 result = 31 * result + (path != null ? path .hashCode () : 0 );
118+ result = 31 * result + (schemaPath != null ? schemaPath .hashCode () : 0 );
102119 result = 31 * result + (details != null ? details .hashCode () : 0 );
103120 result = 31 * result + (arguments != null ? Arrays .hashCode (arguments ) : 0 );
104121 result = 31 * result + (message != null ? message .hashCode () : 0 );
@@ -113,17 +130,17 @@ public void setType(String type) {
113130 this .type = type ;
114131 }
115132
116- public static ValidationMessage of (String type , ErrorMessageType errorMessageType , String at , String ... arguments ) {
133+ public static ValidationMessage of (String type , ErrorMessageType errorMessageType , String at , String schemaPath , String ... arguments ) {
117134 ValidationMessage .Builder builder = new ValidationMessage .Builder ();
118- builder .code (errorMessageType .getErrorCode ()).path (at ).arguments (arguments )
135+ builder .code (errorMessageType .getErrorCode ()).path (at ).schemaPath ( schemaPath ). arguments (arguments )
119136 .format (errorMessageType .getMessageFormat ()).type (type )
120137 .customMessage (errorMessageType .getCustomMessage ());
121138 return builder .build ();
122139 }
123140
124- public static ValidationMessage of (String type , ErrorMessageType errorMessageType , String at , Map <String , Object > details ) {
141+ public static ValidationMessage of (String type , ErrorMessageType errorMessageType , String at , String schemaPath , Map <String , Object > details ) {
125142 ValidationMessage .Builder builder = new ValidationMessage .Builder ();
126- builder .code (errorMessageType .getErrorCode ()).path (at ).details (details )
143+ builder .code (errorMessageType .getErrorCode ()).path (at ).schemaPath ( schemaPath ). details (details )
127144 .format (errorMessageType .getMessageFormat ()).type (type );
128145 return builder .build ();
129146 }
@@ -132,6 +149,7 @@ public static class Builder {
132149 private String type ;
133150 private String code ;
134151 private String path ;
152+ private String schemaPath ;
135153 private String [] arguments ;
136154 private Map <String , Object > details ;
137155 private MessageFormat format ;
@@ -152,6 +170,11 @@ public Builder path(String path) {
152170 return this ;
153171 }
154172
173+ public Builder schemaPath (String schemaPath ) {
174+ this .schemaPath = schemaPath ;
175+ return this ;
176+ }
177+
155178 public Builder arguments (String ... arguments ) {
156179 this .arguments = arguments ;
157180 return this ;
@@ -177,6 +200,7 @@ public ValidationMessage build() {
177200 msg .setType (type );
178201 msg .setCode (code );
179202 msg .setPath (path );
203+ msg .setSchemaPath (schemaPath );
180204 msg .setArguments (arguments );
181205 msg .setDetails (details );
182206
0 commit comments