JSONSchema 0.6.0

JSONSchema 0.6.0

TestsTested
LangLanguage SwiftSwift
License BSD-3-Clause
ReleasedLast Release Mar 2021
SwiftSwift Version 5
SPMSupports SPM

Maintained by Kyle Fuller.



JSON Schema

An implementation of JSON Schema in Swift. Supporting JSON Schema Draft 4, 6 and 7.

JSONSchema.swift does not support remote referencing #9.

Installation

JSONSchema can be installed via CocoaPods.

pod 'JSONSchema'

Usage

import JSONSchema

JSONSchema.validate(["name": "Eggs", "price": 34.99], schema: [
  "type": "object",
  "properties": [
    "name": ["type": "string"],
    "price": ["type": "number"],
  ],
  "required": ["name"],
])

Error handling

Validate returns an enumeration ValidationResult which contains all validation errors.

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

License

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