validation_contract 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec_status +29 -21
- data/README.md +15 -11
- data/lib/validation_contract.rb +12 -5
- data/lib/validation_contract/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: 4cbe5e6cf4baf49f568b2218bc82d4d4292ce82d
|
4
|
+
data.tar.gz: af97664b9606c60825a76c1d7ded6b713448d4c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c85bf36763459349b543d46eee8180c3a91e647db6d507a64725c9593eda474bfb42c6a411584c995028f6f27c1adf4ebd4b13d51cf62bd3881717fa51953ba0
|
7
|
+
data.tar.gz: 7174b2e5533625432dd121ba4496dbeb950fecc3e5f9bf04ec7eb8e24ea0bdc2d8b179054b4d3ab1efb2d1d17128431a09306494532528b9d421641343c58b36
|
data/.rspec_status
CHANGED
@@ -1,23 +1,31 @@
|
|
1
1
|
example_id | status | run_time |
|
2
2
|
------------------------------------------ | ------ | --------------- |
|
3
|
-
./spec/validation_contract_spec.rb[1:1] | passed | 0.
|
4
|
-
./spec/validation_contract_spec.rb[1:2] | passed | 0.
|
5
|
-
./spec/validation_contract_spec.rb[1:3:1] | passed | 0.
|
6
|
-
./spec/validation_contract_spec.rb[1:4:1] | passed | 0.
|
7
|
-
./spec/validation_contract_spec.rb[1:4:2] | passed | 0.
|
8
|
-
./spec/validation_contract_spec.rb[1:5:1] | passed | 0.
|
9
|
-
./spec/validation_contract_spec.rb[1:5:2] | passed | 0.
|
10
|
-
./spec/validation_contract_spec.rb[1:5:3] | passed | 0.
|
11
|
-
./spec/validation_contract_spec.rb[1:6:1] | passed | 0.
|
12
|
-
./spec/validation_contract_spec.rb[1:6:2] | passed | 0.
|
13
|
-
./spec/validation_contract_spec.rb[1:6:3] | passed | 0.
|
14
|
-
./spec/validation_contract_spec.rb[1:7:1] | passed | 0.
|
15
|
-
./spec/validation_contract_spec.rb[1:7:2] | passed | 0.
|
16
|
-
./spec/validation_contract_spec.rb[1:8:1] | passed | 0.
|
17
|
-
./spec/validation_contract_spec.rb[1:8:2] | passed | 0.
|
18
|
-
./spec/validation_contract_spec.rb[1:9:1] | passed | 0.
|
19
|
-
./spec/validation_contract_spec.rb[1:9:2] | passed | 0.
|
20
|
-
./spec/validation_contract_spec.rb[1:
|
21
|
-
./spec/validation_contract_spec.rb[1:10:
|
22
|
-
./spec/validation_contract_spec.rb[1:
|
23
|
-
./spec/validation_contract_spec.rb[1:
|
3
|
+
./spec/validation_contract_spec.rb[1:1] | passed | 0.00078 seconds |
|
4
|
+
./spec/validation_contract_spec.rb[1:2] | passed | 0.00013 seconds |
|
5
|
+
./spec/validation_contract_spec.rb[1:3:1] | passed | 0.00012 seconds |
|
6
|
+
./spec/validation_contract_spec.rb[1:4:1] | passed | 0.0001 seconds |
|
7
|
+
./spec/validation_contract_spec.rb[1:4:2] | passed | 0.0005 seconds |
|
8
|
+
./spec/validation_contract_spec.rb[1:5:1] | passed | 0.00053 seconds |
|
9
|
+
./spec/validation_contract_spec.rb[1:5:2] | passed | 0.00011 seconds |
|
10
|
+
./spec/validation_contract_spec.rb[1:5:3] | passed | 0.0001 seconds |
|
11
|
+
./spec/validation_contract_spec.rb[1:6:1] | passed | 0.00009 seconds |
|
12
|
+
./spec/validation_contract_spec.rb[1:6:2] | passed | 0.0001 seconds |
|
13
|
+
./spec/validation_contract_spec.rb[1:6:3] | passed | 0.00011 seconds |
|
14
|
+
./spec/validation_contract_spec.rb[1:7:1] | passed | 0.00016 seconds |
|
15
|
+
./spec/validation_contract_spec.rb[1:7:2] | passed | 0.00013 seconds |
|
16
|
+
./spec/validation_contract_spec.rb[1:8:1] | passed | 0.00027 seconds |
|
17
|
+
./spec/validation_contract_spec.rb[1:8:2] | passed | 0.00014 seconds |
|
18
|
+
./spec/validation_contract_spec.rb[1:9:1] | passed | 0.00014 seconds |
|
19
|
+
./spec/validation_contract_spec.rb[1:9:2] | passed | 0.0001 seconds |
|
20
|
+
./spec/validation_contract_spec.rb[1:9:3] | passed | 0.00016 seconds |
|
21
|
+
./spec/validation_contract_spec.rb[1:10:1] | passed | 0.00017 seconds |
|
22
|
+
./spec/validation_contract_spec.rb[1:10:2] | passed | 0.00012 seconds |
|
23
|
+
./spec/validation_contract_spec.rb[1:10:3] | passed | 0.00008 seconds |
|
24
|
+
./spec/validation_contract_spec.rb[1:11:1] | passed | 0.0002 seconds |
|
25
|
+
./spec/validation_contract_spec.rb[1:11:2] | passed | 0.00016 seconds |
|
26
|
+
./spec/validation_contract_spec.rb[1:12:1] | passed | 0.00012 seconds |
|
27
|
+
./spec/validation_contract_spec.rb[1:12:2] | passed | 0.00012 seconds |
|
28
|
+
./spec/validation_contract_spec.rb[1:13:1] | passed | 0.00011 seconds |
|
29
|
+
./spec/validation_contract_spec.rb[1:13:2] | passed | 0.0001 seconds |
|
30
|
+
./spec/validation_contract_spec.rb[1:14:1] | passed | 0.00009 seconds |
|
31
|
+
./spec/validation_contract_spec.rb[1:14:2] | passed | 0.00008 seconds |
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# ValidationContract
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/validation_contract.svg)](https://rubygems.org/gems/validation_contract)
|
3
|
-
|
3
|
+
![ruby](https://img.shields.io/badge/Ruby-2.4.2-green.svg)
|
4
|
+
[![Build Status](https://travis-ci.org/grassiricardo/validation_contract.svg?branch=master)](https://travis-ci.org/grassiricardo/validation_contract)
|
5
|
+
[![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)
|
4
6
|
|
5
7
|
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
8
|
|
@@ -50,16 +52,17 @@ This will check if there is any invalid field, if there is an arry returned with
|
|
50
52
|
|
51
53
|
| Validation | Example | Done |
|
52
54
|
| ------------- |:---------------------------------------------------:| -----:|
|
53
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
| errors | Return errors |
|
61
|
-
| clear | Clears the arry error |
|
62
|
-
|
|
55
|
+
| required | validate if field is required | V |
|
56
|
+
| has_min_len | check if the field has a minimum of characters | V |
|
57
|
+
| has_max_len | checks if the field has a maximum of characters | V |
|
58
|
+
| fixed_len | checks if there is an x quantity of | V |
|
59
|
+
| email | check if email is valid | V |
|
60
|
+
| greater_than | valid if one number is greater than another | V |
|
61
|
+
| lower_than | valid if one number is smaller than another | V |
|
62
|
+
| errors | Return errors | V |
|
63
|
+
| clear | Clears the arry error | V |
|
64
|
+
| valid | Check whether this arry is valid or not | V |
|
65
|
+
| url | check if url is valid | V |
|
63
66
|
|
64
67
|
## Contributing
|
65
68
|
|
@@ -72,6 +75,7 @@ This will check if there is any invalid field, if there is an arry returned with
|
|
72
75
|
## Contributor
|
73
76
|
|
74
77
|
[Ricardo Grassi](https://github.com/grassiricardo).
|
78
|
+
|
75
79
|
[Alan Lira](https://github.com/lira92).
|
76
80
|
|
77
81
|
## License
|
data/lib/validation_contract.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "validation_contract/version"
|
2
|
+
require 'uri'
|
2
3
|
|
3
4
|
module ValidationContract
|
4
5
|
class Validations
|
@@ -7,7 +8,7 @@ module ValidationContract
|
|
7
8
|
@errors = []
|
8
9
|
end
|
9
10
|
|
10
|
-
def
|
11
|
+
def required value, message
|
11
12
|
if !value || value.length() <= 0
|
12
13
|
@errors.push({message: message})
|
13
14
|
end
|
@@ -25,30 +26,36 @@ module ValidationContract
|
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
|
-
def
|
29
|
+
def fixed_len value, len, message
|
29
30
|
if value.length() != len
|
30
31
|
@errors.push({message: message})
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
34
|
-
def
|
35
|
+
def email value, message
|
35
36
|
if !value.match(/\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i)
|
36
37
|
@errors.push({message: message})
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
|
-
def
|
41
|
+
def greater_than value, comparer, message
|
41
42
|
if value <= comparer
|
42
43
|
@errors.push({message: message})
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
46
|
-
def
|
47
|
+
def lower_than value, comparer, message
|
47
48
|
if value >= comparer
|
48
49
|
@errors.push({message: message})
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
53
|
+
def url value, message
|
54
|
+
if !value.match(URI.regexp)
|
55
|
+
@errors.push({message: message})
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
52
59
|
def erros
|
53
60
|
return @errors
|
54
61
|
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.10
|
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-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|