All Projects → kylef → Jsonschema.swift

kylef / Jsonschema.swift

Licence: bsd-3-clause
JSON Schema validator in Swift

Programming Languages

swift
15916 projects

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

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].