Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/beauby/jsonapi-validations
[DEPRECATED] Ruby gem for validating JSONAPI payloads.
https://github.com/beauby/jsonapi-validations
Last synced: 6 days ago
JSON representation
[DEPRECATED] Ruby gem for validating JSONAPI payloads.
- Host: GitHub
- URL: https://github.com/beauby/jsonapi-validations
- Owner: beauby
- Created: 2016-10-01T18:03:24.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-07-10T21:17:06.000Z (over 5 years ago)
- Last Synced: 2024-12-01T03:14:54.033Z (24 days ago)
- Language: Ruby
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Deprecated
## This project was abandonned and is not maintained anymore. For validation, see [jsonapi-parser](https://github.com/jsonapi-rb/parser). For deserialization, see [jsonapi-deserializable](https://github.com/jsonapi-rb/deserializable).# jsonapi-validations
Ruby gem for validating [JSON API](http://jsonapi.org) payloads.## Installation
```ruby
# In Gemfile
gem 'jsonapi-validations'
```
then
```
$ bundle
```
or manually via
```
$ gem install jsonapi-validations
```## Usage
First, require the gem:
```ruby
require 'jsonapi/validations'
```
Then validate a resource creation/update payload:
```ruby
params = {
permitted: {
id: true,
attributes: [:name, :address, :birthdate],
relationships: [:posts, :sponsor]
},
required: {
id: true,
attributes: [:name, :address],
relationships: [:sponsor]
},
types: {
primary: [:users, :admins],
relationships: {
posts: {
kind: :has_many,
types: [:blogs, :posts]
}
}
}
}
JSONAPI.validate_resource!(document_hash, params)
```
or a relationship update payload:
```ruby
params = {
kind: :has_many,
types: [:users, :admins]
}
JSONAPI.validate_relationship!(document_hash, params)
```## License
jsonapi-validations is released under the [MIT License](http://www.opensource.org/licenses/MIT).