File tree Expand file tree Collapse file tree 2 files changed +32
-7
lines changed
main/java/com/microsoft/rest
test/java/com/microsoft/rest Expand file tree Collapse file tree 2 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -56,15 +56,29 @@ public static void validate(Object parameter) {
5656 || parameterToken .isSupertypeOf (Period .class )) {
5757 return ;
5858 }
59+ if (TypeToken .of (List .class ).isSupertypeOf (parameterType )) {
60+ List <?> items = (List <?>) parameter ;
61+ for (Object item : items ) {
62+ Validator .validate (item );
63+ }
64+ }
65+ else if (TypeToken .of (Map .class ).isSupertypeOf (parameterType )) {
66+ Map <?, ?> entries = (Map <?, ?>) parameter ;
67+ for (Map .Entry <?, ?> entry : entries .entrySet ()) {
68+ Validator .validate (entry .getKey ());
69+ Validator .validate (entry .getValue ());
70+ }
71+ }
72+ else {
73+ Annotation skipParentAnnotation = parameterType .getAnnotation (SkipParentValidation .class );
5974
60- Annotation skipParentAnnotation = parameterType .getAnnotation (SkipParentValidation .class );
61-
62- if (skipParentAnnotation == null ) {
63- for (Class <?> c : parameterToken .getTypes ().classes ().rawTypes ()) {
64- validateClass (c , parameter );
75+ if (skipParentAnnotation == null ) {
76+ for (Class <?> c : parameterToken .getTypes ().classes ().rawTypes ()) {
77+ validateClass (c , parameter );
78+ }
79+ } else {
80+ validateClass (parameterType , parameter );
6581 }
66- } else {
67- validateClass (parameterType , parameter );
6882 }
6983 }
7084
Original file line number Diff line number Diff line change @@ -98,6 +98,17 @@ public void validateList() throws Exception {
9898 }
9999 }
100100
101+ @ Test
102+ public void validateListParameter () throws Exception {
103+ ListWrapper body = new ListWrapper ();
104+ body .list = new ArrayList <StringWrapper >();
105+ Validator .validate (body ); // pass
106+ StringWrapper wrapper = new StringWrapper ();
107+ wrapper .value = "valid" ;
108+ body .list .add (wrapper );
109+ Validator .validate (body .list ); // pass
110+ }
111+
101112 @ Test
102113 public void validateMap () throws Exception {
103114 MapWrapper body = new MapWrapper ();
You can’t perform that action at this time.
0 commit comments