@@ -224,86 +224,106 @@ schema_unsupported_test() ->
224224-ifndef (erlang_deprecated_types ).
225225-ifndef (COMMON_TEST ). % see Emakefile
226226map_schema_test () ->
227- [map_schema_test_draft (URI )
228- || URI <- [<<" http://json-schema.org/draft-03/schema#" >>,
229- <<" http://json-schema.org/draft-04/schema#" >>]].
227+ [ map_schema_test_draft (URI )
228+ || URI <- [ <<" http://json-schema.org/draft-03/schema#" >>
229+ , <<" http://json-schema.org/draft-04/schema#" >>
230+ ]].
230231
231232map_schema_test_draft (URI ) ->
232- Schema = #{<<" $schema" >> => URI ,
233- <<" type" >> => <<" object" >>,
234- <<" properties" >> =>
235- #{
236- <<" foo" >> =>
237- #{<<" type" >> => <<" object" >>,
238- <<" properties" >> =>
239- #{<<" subfoo" >> => #{<<" type" >> => <<" integer" >>}}
240- }
241- },
242- <<" patternProperties" >> =>
243- #{<<" ^b" >> => #{<<" type" >> => <<" integer" >>}}
233+ Schema = #{ <<" $schema" >> => URI
234+ , <<" type" >> => <<" object" >>
235+ , <<" properties" >> =>
236+ #{ <<" foo" >> =>
237+ #{ <<" type" >> => <<" object" >>
238+ , <<" properties" >> =>
239+ #{ <<" subfoo" >> => #{ <<" type" >> => <<" integer" >>
240+ }
241+ }
242+ }
243+ }
244+ , <<" patternProperties" >> =>
245+ #{ <<" ^b" >> => #{ <<" type" >> => <<" integer" >>
246+ }
247+ }
244248 },
245- ValidJson = {[ {<<" foo" >>, {[ {<<" subfoo" >>, 42 } ]}},
246- {<<" bar" >>, 42 },
247- {<<" baz" >>, 42 }
248- ]},
249+ ValidJson = {[ {<<" foo" >>, {[ {<<" subfoo" >>, 42 } ]}}
250+ , {<<" bar" >>, 42 }
251+ , {<<" baz" >>, 42 }
252+ ]},
249253 ? assertEqual ({ok , ValidJson } ,
250254 jesse_schema_validator :validate (Schema , ValidJson , [])),
251255
252256 InvalidJson = {[ {<<" bar" >>, <<" str expect int" >>} ]},
253- ? assertThrow ([{data_invalid ,
254- #{<<" type" >> := <<" integer" >>},
255- wrong_type ,
256- <<" str expect int" >>,
257- [<<" bar" >>]}],
257+ ? assertThrow ([{ data_invalid
258+ , #{<<" type" >> := <<" integer" >>}
259+ , wrong_type
260+ , <<" str expect int" >>
261+ , [<<" bar" >>]
262+ }],
258263 jesse_schema_validator :validate (Schema , InvalidJson , [])).
259264
260265
261266map_data_test () ->
262- [map_data_test_draft (URI )
263- || URI <- [<<" http://json-schema.org/draft-03/schema#" >>,
264- <<" http://json-schema.org/draft-04/schema#" >>]].
267+ [ map_data_test_draft (URI )
268+ || URI <- [ <<" http://json-schema.org/draft-03/schema#" >>
269+ , <<" http://json-schema.org/draft-04/schema#" >>
270+ ]
271+ ].
265272
266273
267274map_data_test_draft (URI ) ->
268- Schema = {[ {<<" $schema" >>, URI },
269- {<<" type" >>, <<" object" >>},
270- {<<" properties" >>,
271- {[
272- {<<" foo" >>,
273- {[ {<<" type" >>, <<" object" >>},
274- {<<" properties" >>,
275- {[ {<<" subfoo" >>, {[ {<<" type" >>, <<" integer" >>} ]}} ]}
276- }
277- ]}
278- }
279- ]}
280- },
281- {<<" patternProperties" >>,
282- {[ {<<" ^b" >>, {[ {<<" type" >>, <<" integer" >>} ]}} ]}}
275+ Schema = {[ {<<" $schema" >>, URI }
276+ , {<<" type" >>, <<" object" >>}
277+ , {<<" properties" >>
278+ , {[{ <<" foo" >>
279+ , {[ {<<" type" >>, <<" object" >>}
280+ , { <<" properties" >>
281+ , {[{ <<" subfoo" >>
282+ , {[{ <<" type" >>
283+ , <<" integer" >>
284+ }]}
285+ }]}
286+ }
287+ ]}
288+ }
289+ ]}
290+ }
291+ , { <<" patternProperties" >>
292+ , {[{ <<" ^b" >>
293+ , {[{<<" type" >>, <<" integer" >>}]}
294+ }]}}
283295 ]},
284- ValidJson = #{<<" foo" >> => #{<<" subfoo" >> => 42 },
285- <<" bar" >> => 42 ,
286- <<" baz" >> => 42
287- },
288- ? assertEqual ({ok , ValidJson } ,
289- jesse_schema_validator :validate (Schema , ValidJson , [])),
296+ ValidJson = #{ <<" foo" >> => #{<<" subfoo" >> => 42 }
297+ , <<" bar" >> => 42
298+ , <<" baz" >> => 42
299+ },
300+ ? assertEqual ( {ok , ValidJson }
301+ , jesse_schema_validator :validate (Schema , ValidJson , [])
302+ ),
290303
291- InvalidJson = #{<<" foo" >> => 42 ,
292- <<" baz" >> => #{}},
304+ InvalidJson = #{ <<" foo" >> => 42
305+ , <<" baz" >> => #{}
306+ },
293307 % % XXX: order of errors isn't guaranteed
294308 % % In case of future fails it can be replaced with manual catching and sorting
295309 % % of throwed error list, then checked using ?assertMatch
296- ? assertThrow ([{data_invalid ,
297- {[ {<<" type" >>, <<" object" >>} | _ ]},
298- wrong_type , 42 ,
299- [<<" foo" >>]}
300- ,{data_invalid ,
301- {[ {<<" type" >>, <<" integer" >>} ]},
302- wrong_type , #{},
303- [<<" baz" >>]}
304- ],
305- jesse_schema_validator :validate (Schema , InvalidJson ,
306- [{allowed_errors , infinity }])).
310+ ? assertThrow ([ { data_invalid
311+ , {[{<<" type" >>, <<" object" >>} | _ ]}
312+ , wrong_type
313+ , 42
314+ , [<<" foo" >>]
315+ }
316+ , { data_invalid
317+ , {[{<<" type" >>, <<" integer" >>}]}
318+ , wrong_type
319+ , #{}
320+ , [<<" baz" >>]
321+ }
322+ ],
323+ jesse_schema_validator :validate ( Schema
324+ , InvalidJson
325+ , [{allowed_errors , infinity }]
326+ )).
307327
308328-endif .
309329-endif .
0 commit comments