hash_validator 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -6
- data/lib/hash_validator.rb +4 -4
- data/lib/hash_validator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a1492f217366ea561ca20646b123578e23a3d08
|
4
|
+
data.tar.gz: 9bfa7a9b44345a7bcca3837ee439b38db1f76bd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d4026acaac90a08173375923d6932b68d7151c2c1a6d3b7f5df82f2373111909d08b70f052a8bb4dd9010019480985ce90497296ef9630ada45b387f130bfe1
|
7
|
+
data.tar.gz: 3384677eaef109084a8d8089f21cb82c7a25d78ec5c4eb25554bcd26d8c451156328d64abcdfb5b330fad9849f4468632558fab69a2ab67b1a00a416d4d640cd
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Hash Validator
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/JamesBrooks/hash_validator.png)](https://travis-ci.org/JamesBrooks/hash_validator)
|
4
|
-
[![Code Climate](https://codeclimate.com/github/JamesBrooks/hash_validator.png)](https://codeclimate.com/github/JamesBrooks/
|
5
|
-
[![Gem Version](https://badge.fury.io/rb/hash_validator.png)](http://badge.fury.io/rb/
|
6
|
-
[![Dependency Status](https://gemnasium.com/JamesBrooks/hash_validator.png)](https://gemnasium.com/JamesBrooks/
|
4
|
+
[![Code Climate](https://codeclimate.com/github/JamesBrooks/hash_validator.png)](https://codeclimate.com/github/JamesBrooks/hash_validator)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/hash_validator.png)](http://badge.fury.io/rb/hash_validator)
|
6
|
+
[![Dependency Status](https://gemnasium.com/JamesBrooks/hash_validator.png)](https://gemnasium.com/JamesBrooks/hash_validator)
|
7
7
|
|
8
8
|
Ruby library to validate hashes (Hash) against user-defined requirements
|
9
9
|
|
@@ -22,7 +22,8 @@ Or install it yourself as:
|
|
22
22
|
$ gem install hash_validator
|
23
23
|
|
24
24
|
## Example
|
25
|
-
|
25
|
+
|
26
|
+
```ruby
|
26
27
|
# Validations hash
|
27
28
|
validations = {
|
28
29
|
user: {
|
@@ -52,11 +53,11 @@ validator.errors
|
|
52
53
|
# {
|
53
54
|
:user => {
|
54
55
|
:last_name => "should be string",
|
55
|
-
|
56
|
+
:age => "numeric required",
|
56
57
|
:likes => "array required"
|
57
58
|
}
|
58
59
|
}
|
59
|
-
|
60
|
+
```
|
60
61
|
|
61
62
|
## Usage
|
62
63
|
|
@@ -68,6 +69,8 @@ Define a validation hash which will be used to validate. This has can be nested
|
|
68
69
|
* `time`
|
69
70
|
* hashes are validates by nesting validations, or if just the presence of a hash is required `{}` can be used.
|
70
71
|
|
72
|
+
Example use-cases include Ruby APIs (I'm currently using it in a Rails API that I'm building for better error responses to developers).
|
73
|
+
|
71
74
|
## Contributing
|
72
75
|
|
73
76
|
1. Fork it
|
data/lib/hash_validator.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require 'hash_validator/base'
|
2
|
-
require 'hash_validator/version'
|
3
|
-
require 'hash_validator/validators'
|
4
|
-
|
5
1
|
module HashValidator
|
6
2
|
def self.validate(*args)
|
7
3
|
Base.validate(*args)
|
8
4
|
end
|
9
5
|
end
|
6
|
+
|
7
|
+
require 'hash_validator/base'
|
8
|
+
require 'hash_validator/version'
|
9
|
+
require 'hash_validator/validators'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Brooks
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|