Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kylef/jsonschema.swift
JSON Schema validator in Swift
https://github.com/kylef/jsonschema.swift
Last synced: 5 days ago
JSON representation
JSON Schema validator in Swift
- Host: GitHub
- URL: https://github.com/kylef/jsonschema.swift
- Owner: kylef
- License: bsd-3-clause
- Created: 2015-03-07T10:57:16.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2023-07-25T17:45:55.000Z (over 1 year ago)
- Last Synced: 2024-12-29T10:12:28.141Z (13 days ago)
- Language: Swift
- Homepage:
- Size: 224 KB
- Stars: 275
- Watchers: 9
- Forks: 76
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# JSON Schema
An implementation of [JSON Schema](http://json-schema.org/) 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](https://github.com/kylef/JSONSchema.swift/issues/9).
## Installation
JSONSchema can be installed via [CocoaPods](http://cocoapods.org/).
```ruby
pod 'JSONSchema'
```## Usage
```swift
import JSONSchematry 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.```python
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](LICENSE) for more
info.