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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c004bfbb9a6040860c61e86523746ab12a0e72b4
4
- data.tar.gz: a3bbebda32b72facf3835f09c8d7ac0ac608b821
3
+ metadata.gz: 9b8dae2c5910ea60253b0d283b21d5bab316e73f
4
+ data.tar.gz: b03139fd64d5dedd3ae1ecdda5faf8a75c2e8a1d
5
5
  SHA512:
6
- metadata.gz: 46953df67654b70adf2bdde4cc2bd18839aa362774718f16ecb5d28c64e7a90102daa4ee106beb9d575b623642ae8a1d4fcc6781fe035dd3f0939ea569f28710
7
- data.tar.gz: 23ee36ef6a911e1957767c2d84a3abc779ba557be69fbf50fa909b0204e08a02c979a91e415c4f482b0c92a6b1bec3e2dc3bcd64c75dd234a3e51d8588e3a41d
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
- Validations of the day day for your rails project
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
- - is_required => 'validate if field is required'
48
- - has_min_len => 'check if the field has a minimum of characters'
49
- - has_max_len => 'checks if the field has a maximum of characters'
50
- - is_fixed_len => Checks if there is an x ​​quantity of '
51
- - is_email => 'Check if email is valid'
52
- - errors => 'Return errors'
53
- - clear => 'Clears the arry error'
54
- - is_valid => 'Check whether this arry is valid or not'
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
 
@@ -1,3 +1,3 @@
1
1
  module ValidationContract
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -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.8
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-07 00:00:00.000000000 Z
11
+ date: 2017-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler