JSON Schema validator in Swift
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


JSON Schema

An implementation of JSON Schema in Swift.


CocoaPods is the recommended installation method.

pod 'JSONSchema'


import JSONSchema

let schema = Schema([
    "type": "object",
    "properties": [
        "name": ["type": "string"],
        "price": ["type": "number"],
    "required": ["name"],

schema.validate(["name": "Eggs", "price": 34.99])

Error handling

Validate returns an enumeration ValidationResult which contains all validation errors.

print(schema.validate(["price": 34.99]).errors)
>>> "Required property 'name' is missing."

JSONSchema has full support for the draft4 of the specification. It does not yet support remote referencing #9.


JSONSchema is licensed under the BSD license. See LICENSE for more info.