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
238 Stars 62 Forks BSD 3-Clause "New" or "Revised" License 208 Commits 14 Opened issues

Description

JSON Schema validator in Swift

Services available

!
?

Need anything else?

Contributors list

# 3,538
Objecti...
api-blu...
cocoapo...
Xcode
180 commits
# 658,717
Python
JavaScr...
1 commit
# 19,253
cocoapo...
mac
swift5-...
swift-3
1 commit
# 173,931
Swift
Objecti...
1 commit
# 132,343
Swift
vapor
swift-f...
swift4
1 commit
# 486,232
Swift
Objecti...
Shell
1 commit
# 375,188
C
swift-s...
tcp-soc...
Objecti...
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.