Skip to content

Commit d890802

Browse files
committed
Added more detail to the readme
1 parent 51f0f09 commit d890802

File tree

1 file changed

+4
-24
lines changed

1 file changed

+4
-24
lines changed

README.md

+4-24
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,9 @@
55

66
JsonValidator is an ActiveModel validator that validates any hash field against [JSONSchema](http://json-schema.org), returning errors in the model's own `errors` attribute.
77

8-
## Installation
8+
This gem was originally written to provide deep validation of JSON attributes, which are available alongside primative types in recent versions of [PostgreSQL](http://www.postgresql.org), but it works equally well with ActiveModel objects.
99

10-
Add this line to your application's Gemfile:
11-
12-
gem 'json_validator'
13-
14-
And then execute:
15-
16-
$ bundle
17-
18-
Or install it yourself as:
19-
20-
$ gem install json_validator
10+
Most of the functionality is dependent on the wonderful [json-schema](https://github.com/hoxworth/json-schema) gem.
2111

2212
## Usage
2313

@@ -39,16 +29,6 @@ If you're using Ruby on Rails and ActiveRecord, add a validation to your model l
3929
}
4030
end
4131

42-
Then whenever an instance of `Foo` is saved, `Foo.bar` (assumed to be a hash) will be validated against the inline schema specified (eg. `Foo.new(bar: { handleSize: -10 })` would be invalid, but `Foo.new(bar: { handleSize: 10 })` would be valid).
43-
44-
Notes:
45-
* `schema` can be a hash or a Proc (if you'd like to define it dynamically)
46-
* If you're using ActiveModel without Rails the process is the same.
47-
48-
## Contributing
32+
Then whenever an instance of `Foo` is saved, `Foo.bar` (assumed to be a hash) will be validated against the JSON schema specified. In this case, `Foo.new(bar: { handleSize: -10 })` would be invalid, but `Foo.new(bar: { handleSize: 10 })` would be valid.
4933

50-
1. Fork it ( https://github.com/[my-github-username]/json_validator/fork )
51-
2. Create your feature branch (`git checkout -b my-new-feature`)
52-
3. Commit your changes (`git commit -am 'Add some feature'`)
53-
4. Push to the branch (`git push origin my-new-feature`)
54-
5. Create a new Pull Request
34+
The attribute being validated can be either a hash or a string (which will be parsed as JSON). The schema can be either a hash or a Proc that returns a hash (if you'd like to decide on the schema at runtime), and there's no reason why you could not load your schema from a .json file.

0 commit comments

Comments
 (0)