Need help with JSONSchema.swift?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

kylef
227 Stars 49 Forks BSD 3-Clause "New" or "Revised" License 202 Commits 8 Opened issues

Description

JSON Schema validator in Swift

Services available

!
?

Need anything else?

Contributors list

# 3,144
Objecti...
api-blu...
mac
sasl
176 commits
# 663,424
Swift
Python
1 commit
# 17,520
cocoapo...
mac
swift5-...
swift-3
1 commit
# 164,345
Swift
Objecti...
1 commit
# 126,838
Swift
vapor
swift-f...
swift4
1 commit
# 479,608
Objecti...
Shell
Swift
1 commit
# 431,947
Swift
promise
C
swift-s...
1 commit

JSON Schema

An implementation of JSON Schema in Swift. Supporting JSON Schema Draft 4, 6, 7, 2019-09, 2020-12.

The JSON Schema 2019-09 and 2020-12 support are incomplete and have gaps with some of the newer keywords.

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.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.