validation_contract 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.byebug_history +8 -0
- data/.rspec +2 -0
- data/.rspec_status +23 -0
- data/Gemfile +1 -0
- data/README.md +1 -1
- data/Rakefile +4 -0
- data/bin/console +1 -3
- data/lib/validation_contract/version.rb +1 -1
- data/lib/validation_contract.rb +37 -33
- data/validation_contract.gemspec +1 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c004bfbb9a6040860c61e86523746ab12a0e72b4
|
4
|
+
data.tar.gz: a3bbebda32b72facf3835f09c8d7ac0ac608b821
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46953df67654b70adf2bdde4cc2bd18839aa362774718f16ecb5d28c64e7a90102daa4ee106beb9d575b623642ae8a1d4fcc6781fe035dd3f0939ea569f28710
|
7
|
+
data.tar.gz: 23ee36ef6a911e1957767c2d84a3abc779ba557be69fbf50fa909b0204e08a02c979a91e415c4f482b0c92a6b1bec3e2dc3bcd64c75dd234a3e51d8588e3a41d
|
data/.byebug_history
ADDED
data/.rspec
ADDED
data/.rspec_status
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
example_id | status | run_time |
|
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 |
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -62,7 +62,7 @@ This will check if there is any invalid field, if there is an arry returned with
|
|
62
62
|
4. Push to the branch (git push origin my-new-feature)
|
63
63
|
5. Create new Pull Request
|
64
64
|
|
65
|
-
##
|
65
|
+
## Contributor
|
66
66
|
|
67
67
|
[Ricardo Grassi](https://github.com/grassiricardo).
|
68
68
|
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
1
|
require "bundler/setup"
|
4
|
-
require "
|
2
|
+
require "translate_yandex"
|
5
3
|
|
6
4
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
5
|
# with your gem easier. You can also use a different console, if you like.
|
data/lib/validation_contract.rb
CHANGED
@@ -1,49 +1,53 @@
|
|
1
|
-
|
1
|
+
require "validation_contract/version"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
end
|
3
|
+
module ValidationContract
|
4
|
+
class Validations
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
@errors.push({message: message})
|
6
|
+
def initialize
|
7
|
+
@errors = []
|
10
8
|
end
|
11
|
-
end
|
12
9
|
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
def is_required value, message
|
11
|
+
if !value || value.length() <= 0
|
12
|
+
@errors.push({message: message})
|
13
|
+
end
|
16
14
|
end
|
17
|
-
end
|
18
15
|
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
def has_min_len value, min, message
|
17
|
+
if !value || value.length() < min
|
18
|
+
@errors.push({message: message})
|
19
|
+
end
|
22
20
|
end
|
23
|
-
end
|
24
21
|
|
25
|
-
|
26
|
-
|
27
|
-
|
22
|
+
def has_max_len value, max, message
|
23
|
+
if !value || value.length() > max
|
24
|
+
@errors.push({message: message})
|
25
|
+
end
|
28
26
|
end
|
29
|
-
end
|
30
27
|
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
def is_fixed_len value, len, message
|
29
|
+
if value.length() != len
|
30
|
+
@errors.push({message: message})
|
31
|
+
end
|
34
32
|
end
|
35
|
-
end
|
36
33
|
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
def is_email value, message
|
35
|
+
if !value.match(/\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i)
|
36
|
+
@errors.push({message: message})
|
37
|
+
end
|
38
|
+
end
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
def erros
|
41
|
+
return @errors
|
42
|
+
end
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
def clear
|
45
|
+
return @errors = []
|
46
|
+
end
|
48
47
|
|
48
|
+
def is_valid
|
49
|
+
return @errors.length == 0
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
49
53
|
end
|
data/validation_contract.gemspec
CHANGED
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.8
|
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-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
41
55
|
description: With this gem you will have several validations that are common on day
|
42
56
|
day and that will make life much easier for dev. Validations can be returned in
|
43
57
|
a simple and standardized way..
|
@@ -47,7 +61,10 @@ executables: []
|
|
47
61
|
extensions: []
|
48
62
|
extra_rdoc_files: []
|
49
63
|
files:
|
64
|
+
- ".byebug_history"
|
50
65
|
- ".gitignore"
|
66
|
+
- ".rspec"
|
67
|
+
- ".rspec_status"
|
51
68
|
- Gemfile
|
52
69
|
- README.md
|
53
70
|
- Rakefile
|