JSONSchema 0.3.0

JSONSchema 0.3.0

TestsTested
LangLanguage SwiftSwift
License BSD
ReleasedLast Release May 2016
SPMSupports SPM

Maintained by Kyle Fuller.


Downloads

Total26,175
Week0
Month0

Installs

Apps234
Test Targets65
powered by Segment

GitHub

Stars155
Watchers6
Forks29
Issues4
Contributors2
Pull Requests5

Code

Files3
LOCLines of Code 601


JSON Schema

An implementation of JSON Schema in Swift.

Installation

CocoaPods is the recommended installation method.

pod 'JSONSchema'

Usage

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.

println(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.

License

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