An implementation of JSON Schema in Swift. Supporting JSON Schema Draft 4, 6 and 7.
JSONSchema.swift does not support remote referencing #9.
JSONSchema can be installed via CocoaPods.
pod 'JSONSchema'
import JSONSchema
JSONSchema.validate(["name": "Eggs", "price": 34.99], schema: [
"type": "object",
"properties": [
"name": ["type": "string"],
"price": ["type": "number"],
],
"required": ["name"],
])
Validate returns an enumeration ValidationResult
which contains all
validation errors.
print(validate(["price": 34.99], schema: ["required": ["name"]]).errors)
>>> "Required property 'name' is missing."
JSONSchema is licensed under the BSD license. See LICENSE for more info.