validation_contract 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -11
- data/lib/validation_contract/version.rb +1 -1
- data/lib/validation_contract.rb +12 -0
- 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: 9b8dae2c5910ea60253b0d283b21d5bab316e73f
|
4
|
+
data.tar.gz: b03139fd64d5dedd3ae1ecdda5faf8a75c2e8a1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2daf6b944be27c4ff48257873ea65f81d3ad8aafd5b1b9fcbeff55723070f8cdec68062407da25beb25c9d875b7e6b00a8c60e7a6407e39fe8096e874d0e7af2
|
7
|
+
data.tar.gz: 9f4ef88208f6ee3a08d84c2cb9e30f9ee69b596c990e113a06edd1969abfef98eec9a281b00ae170fcfea5a26246c42ded9df0020f7fd5b61bff8712090ec6ab
|
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# ValidationContract
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/validation_contract.svg)](https://rubygems.org/gems/validation_contract)
|
3
|
+
[![Build Status](https://app.codeship.com/projects/97a495a0-8bf9-0135-191d-3e39845176c6/status?branch=master)](https://app.codeship.com/projects/97a495a0-8bf9-0135-191d-3e39845176c6/status?branch=master)
|
2
4
|
|
3
|
-
|
5
|
+
This gem and its validations have been implemented on top of the ```Notification Pattern```, which allows API to return all the validations at a single time, improving the user experience.
|
6
|
+
|
7
|
+
Validations of the day day for your rails project.
|
4
8
|
|
5
9
|
With this gem you will have several validations that are common on day day and that will make life much easier for dev. Validations can be returned in a simple and standardized way.
|
6
10
|
|
@@ -24,7 +28,7 @@ Or install it yourself as:
|
|
24
28
|
|
25
29
|
require 'validation_contract'
|
26
30
|
|
27
|
-
validation_contract = ValidationContract.new
|
31
|
+
validation_contract = ValidationContract::Validations.new
|
28
32
|
|
29
33
|
Verifying an invalid email, the return will be an array with message and its validation inside, this will occur for all the desired validations.
|
30
34
|
|
@@ -44,15 +48,18 @@ This will check if there is any invalid field, if there is an arry returned with
|
|
44
48
|
|
45
49
|
## Validations
|
46
50
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
| Validation | Example | Done |
|
52
|
+
| ------------- |:---------------------------------------------------:| -----:|
|
53
|
+
| is_required | validate if field is required | √ |
|
54
|
+
| has_min_len | check if the field has a minimum of characters | √ |
|
55
|
+
| has_max_len | checks if the field has a maximum of characters | √ |
|
56
|
+
| is_fixed_len | checks if there is an x quantity of | √ |
|
57
|
+
| is_email | heck if email is valid | √ |
|
58
|
+
| is_greater_than | valid if one number is greater than another | √ |
|
59
|
+
| is_lower_than | valid if one number is smaller than another | √ |
|
60
|
+
| errors | Return errors | √ |
|
61
|
+
| clear | Clears the arry error | √ |
|
62
|
+
| is_valid | Check whether this arry is valid or not | √ |
|
56
63
|
|
57
64
|
## Contributing
|
58
65
|
|
@@ -65,6 +72,7 @@ This will check if there is any invalid field, if there is an arry returned with
|
|
65
72
|
## Contributor
|
66
73
|
|
67
74
|
[Ricardo Grassi](https://github.com/grassiricardo).
|
75
|
+
[Alan Lira](https://github.com/lira92).
|
68
76
|
|
69
77
|
## License
|
70
78
|
|
data/lib/validation_contract.rb
CHANGED
@@ -37,6 +37,18 @@ module ValidationContract
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
+
def is_greater_than value, comparer, message
|
41
|
+
if value <= comparer
|
42
|
+
@errors.push({message: message})
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def is_lower_than value, comparer, message
|
47
|
+
if value >= comparer
|
48
|
+
@errors.push({message: message})
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
40
52
|
def erros
|
41
53
|
return @errors
|
42
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validation_contract
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- grassiricardo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|