@@ -19,7 +19,7 @@ public class ApiMessageParamValidator implements ApiMessageValidator, Ordered {
1919 @ Override
2020 public void validate (APIMessage msg , Field f , Object value , APIParam at ) {
2121 if (at .required () && value == null ) {
22- throw new InvalidApiMessageException ("field[%s] of message[%s] is mandatory, can not be null" , f .getName (), getClass ().getName ());
22+ throw new InvalidApiMessageException ("field[%s] of message[%s] is mandatory, can not be null" , f .getName (), msg . getClass ().getName ());
2323 }
2424
2525 if (value != null ) {
@@ -32,30 +32,30 @@ private void validateNonNullValue(APIMessage msg, Field f, Object value, APIPara
3232 String str = (String ) value ;
3333 if (str .length () > at .maxLength ()) {
3434 throw new InvalidApiMessageException ("field[%s] of message[%s] exceeds max length of string. expected was <= %s, actual was %s" ,
35- f .getName (), getClass ().getName (), at .maxLength (), str .length ());
35+ f .getName (), msg . getClass ().getName (), at .maxLength (), str .length ());
3636 }
3737 }
3838
3939 if (at .minLength () != 0 && (value instanceof String )) {
4040 String str = (String ) value ;
4141 if (str .length () < at .minLength ()) {
4242 throw new InvalidApiMessageException ("field[%s] of message[%s] less than the min length of string. expected was >= %s, actual was %s" ,
43- f .getName (), getClass ().getName (), at .minLength (), str .length ());
43+ f .getName (), msg . getClass ().getName (), at .minLength (), str .length ());
4444 }
4545 }
4646
4747 if (at .validValues ().length > 0 ) {
4848 Collection <?> values = (value instanceof Collection ) ?
4949 (Collection <?>) value : Collections .singletonList (value );
5050 for (Object v : values ) {
51- validateValue (at .validValues (), v .toString (), f .getName (), getClass ().getName ());
51+ validateValue (at .validValues (), v .toString (), f .getName (), msg . getClass ().getName ());
5252 }
5353 } else if (at .validEnums ().length > 0 ) {
5454 Collection <?> values = (value instanceof Collection ) ?
5555 (Collection <?>) value : Collections .singletonList (value );
5656 final String [] validValues = CollectionUtils .valuesForEnums (at .validEnums ()).toArray (String []::new );
5757 for (Object v : values ) {
58- validateValue (validValues , v .toString (), f .getName (), getClass ().getName ());
58+ validateValue (validValues , v .toString (), f .getName (), msg . getClass ().getName ());
5959 }
6060 }
6161
@@ -65,7 +65,7 @@ private void validateNonNullValue(APIMessage msg, Field f, Object value, APIPara
6565 Matcher mt = p .matcher (value .toString ());
6666 if (!mt .matches ()){
6767 throw new InvalidApiMessageException ("valid regex value for field[%s] of message[%s] are %s, but %s found" , f .getName (),
68- getClass ().getName (), regex , value );
68+ msg . getClass ().getName (), regex , value );
6969 }
7070 }
7171
0 commit comments