@@ -161,6 +161,55 @@ func Test_Validate(t *testing.T) {
161161 },
162162 },
163163 }}, false },
164+ {
165+ "test not required nil filed" ,
166+ args {
167+ data : map [string ]any {
168+ "name" : "John" ,
169+ "age" : 28 ,
170+ "email" : nil ,
171+ },
172+ schema : jsonschema.Definition {
173+ Type : jsonschema .Object ,
174+ Properties : map [string ]jsonschema.Definition {
175+ "name" : {Type : jsonschema .String },
176+ "age" : {Type : jsonschema .Integer },
177+ "email" : {Type : jsonschema .String },
178+ },
179+ Required : []string {"name" , "age" },
180+ },
181+ },
182+ true ,
183+ },
184+ {
185+ "test not required nil object" ,
186+ args {
187+ data : map [string ]any {
188+ "name" : "John" ,
189+ "age" : 28 ,
190+ "address" : nil ,
191+ },
192+ schema : jsonschema.Definition {
193+ Type : jsonschema .Object ,
194+ Properties : map [string ]jsonschema.Definition {
195+ "name" : {Type : jsonschema .String },
196+ "age" : {Type : jsonschema .Integer },
197+ "address" : {
198+ Type : jsonschema .Object ,
199+ Properties : map [string ]jsonschema.Definition {
200+ "street" : {Type : jsonschema .String },
201+ "city" : {Type : jsonschema .String },
202+ "state" : {Type : jsonschema .String },
203+ "zip" : {Type : jsonschema .String },
204+ },
205+ Required : []string {"street" , "city" , "state" , "zip" },
206+ },
207+ },
208+ Required : []string {"name" , "age" },
209+ },
210+ },
211+ true ,
212+ },
164213 }
165214 for _ , tt := range tests {
166215 t .Run (tt .name , func (t * testing.T ) {
0 commit comments