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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b8dae2c5910ea60253b0d283b21d5bab316e73f
4
- data.tar.gz: b03139fd64d5dedd3ae1ecdda5faf8a75c2e8a1d
3
+ metadata.gz: 4cbe5e6cf4baf49f568b2218bc82d4d4292ce82d
4
+ data.tar.gz: af97664b9606c60825a76c1d7ded6b713448d4c0
5
5
  SHA512:
6
- metadata.gz: 2daf6b944be27c4ff48257873ea65f81d3ad8aafd5b1b9fcbeff55723070f8cdec68062407da25beb25c9d875b7e6b00a8c60e7a6407e39fe8096e874d0e7af2
7
- data.tar.gz: 9f4ef88208f6ee3a08d84c2cb9e30f9ee69b596c990e113a06edd1969abfef98eec9a281b00ae170fcfea5a26246c42ded9df0020f7fd5b61bff8712090ec6ab
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.00056 seconds |
4
- ./spec/validation_contract_spec.rb[1:2] | passed | 0.00012 seconds |
5
- ./spec/validation_contract_spec.rb[1:3:1] | passed | 0.00008 seconds |
6
- ./spec/validation_contract_spec.rb[1:4:1] | passed | 0.00008 seconds |
7
- ./spec/validation_contract_spec.rb[1:4:2] | passed | 0.00041 seconds |
8
- ./spec/validation_contract_spec.rb[1:5:1] | passed | 0.00038 seconds |
9
- ./spec/validation_contract_spec.rb[1:5:2] | passed | 0.00008 seconds |
10
- ./spec/validation_contract_spec.rb[1:5:3] | passed | 0.00007 seconds |
11
- ./spec/validation_contract_spec.rb[1:6:1] | passed | 0.00007 seconds |
12
- ./spec/validation_contract_spec.rb[1:6:2] | passed | 0.00007 seconds |
13
- ./spec/validation_contract_spec.rb[1:6:3] | passed | 0.0001 seconds |
14
- ./spec/validation_contract_spec.rb[1:7:1] | passed | 0.00008 seconds |
15
- ./spec/validation_contract_spec.rb[1:7:2] | passed | 0.00007 seconds |
16
- ./spec/validation_contract_spec.rb[1:8:1] | passed | 0.0001 seconds |
17
- ./spec/validation_contract_spec.rb[1:8:2] | passed | 0.00007 seconds |
18
- ./spec/validation_contract_spec.rb[1:9:1] | passed | 0.00009 seconds |
19
- ./spec/validation_contract_spec.rb[1:9:2] | passed | 0.00006 seconds |
20
- ./spec/validation_contract_spec.rb[1:10:1] | passed | 0.00012 seconds |
21
- ./spec/validation_contract_spec.rb[1:10:2] | passed | 0.00007 seconds |
22
- ./spec/validation_contract_spec.rb[1:11:1] | passed | 0.00007 seconds |
23
- ./spec/validation_contract_spec.rb[1:11:2] | passed | 0.00011 seconds |
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
- [![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)
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
- | 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 | |
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
@@ -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 is_required value, message
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 is_fixed_len value, len, message
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 is_email value, message
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 is_greater_than value, comparer, message
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 is_lower_than value, comparer, message
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
@@ -1,3 +1,3 @@
1
1
  module ValidationContract
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  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.9
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-10 00:00:00.000000000 Z
11
+ date: 2017-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler