11# JSON Schema
22
33An implementation of [ JSON Schema] ( http://json-schema.org/ ) in Swift.
4+ Supporting JSON Schema Draft 4, 6 and 7.
5+
6+ JSONSchema.swift does not support remote referencing [ #9 ] ( https://github.com/kylef/JSONSchema.swift/issues/9 ) .
47
58## Installation
69
7- [ CocoaPods] ( http://cocoapods.org/ ) is the recommended installation method .
10+ JSONSchema can be installed via [ CocoaPods] ( http://cocoapods.org/ ) .
811
912``` ruby
1013pod ' JSONSchema'
@@ -15,16 +18,14 @@ pod 'JSONSchema'
1518``` swift
1619import JSONSchema
1720
18- let schema = Schema ( [
19- " type" : " object" ,
20- " properties" : [
21- " name" : [" type" : " string" ],
22- " price" : [" type" : " number" ],
23- ],
24- " required" : [" name" ],
21+ JSONSchema. validate ([ " name " : " Eggs " , " price " : 34.99 ], schema : [
22+ " type" : " object" ,
23+ " properties" : [
24+ " name" : [" type" : " string" ],
25+ " price" : [" type" : " number" ],
26+ ],
27+ " required" : [" name" ],
2528])
26-
27- schema.validate ([" name" : " Eggs" , " price" : 34.99 ])
2829```
2930
3031### Error handling
@@ -33,13 +34,10 @@ Validate returns an enumeration `ValidationResult` which contains all
3334validation errors.
3435
3536``` python
36- print (schema. validate([" price" : 34.99 ]).errors)
37+ print (validate([" price" : 34.99 ], schema: [ " required " : [ " name " ] ]).errors)
3738>> > " Required property 'name' is missing."
3839```
3940
40- JSONSchema has full support for the draft4 of the specification. It does not
41- yet support remote referencing [ #9 ] ( https://github.com/kylef/JSONSchema.swift/issues/9 ) .
42-
4341## License
4442
4543JSONSchema is licensed under the BSD license. See [ LICENSE] ( LICENSE ) for more
0 commit comments