valid 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/validation/rule/uuid.rb +46 -0
- data/lib/validation/validator.rb +1 -0
- data/lib/validation/version.rb +1 -1
- metadata +10 -11
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 95678ed889479acfad08b91569cfc0b9e86b7e45
|
4
|
+
data.tar.gz: 7fbc20b57cefdf16bf094714fc0e2a73e944cbf3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 148beec3403250bd30f51f47f01c9cd67cb89f387614f94bc9ef43a265539de28befc17d85fa2e5c117c2ca27095cac780118d759dd7bebc32abc89f00562d5b
|
7
|
+
data.tar.gz: fcea3fa96b21ddb52186ecabf43392f9e7dc6e4179b1fb7c0c83b568d7d0e3642776705b39f1bf481a4cd8ac425e61e669ef417b290c5528c79f92613233b43b
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Validation
|
2
|
+
# UUID rule
|
3
|
+
module Rule
|
4
|
+
class Uuid
|
5
|
+
class UnknownVersion < StandardError; end
|
6
|
+
# params can be any of the folowing:
|
7
|
+
#
|
8
|
+
# - :version - v4 (only supports v4 at this time)
|
9
|
+
#
|
10
|
+
# Example:
|
11
|
+
#
|
12
|
+
# {:version => v4}
|
13
|
+
def initialize(params)
|
14
|
+
@params = params
|
15
|
+
end
|
16
|
+
|
17
|
+
def params
|
18
|
+
@params
|
19
|
+
end
|
20
|
+
|
21
|
+
def valid_value?(value)
|
22
|
+
value.nil? || !!uuid_regex.match(value.to_s)
|
23
|
+
rescue UnknownVersion
|
24
|
+
false
|
25
|
+
end
|
26
|
+
|
27
|
+
def error_key
|
28
|
+
:uuid
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def uuid_regex
|
34
|
+
if params[:version] == 'v4'
|
35
|
+
uuid_v4_regex
|
36
|
+
else
|
37
|
+
raise UnknownVersion
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def uuid_v4_regex
|
42
|
+
/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/validation/validator.rb
CHANGED
data/lib/validation/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jeremy Bush
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-03-16 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description:
|
15
14
|
email:
|
@@ -18,6 +17,8 @@ executables: []
|
|
18
17
|
extensions: []
|
19
18
|
extra_rdoc_files: []
|
20
19
|
files:
|
20
|
+
- README.md
|
21
|
+
- lib/validation.rb
|
21
22
|
- lib/validation/rule/email.rb
|
22
23
|
- lib/validation/rule/length.rb
|
23
24
|
- lib/validation/rule/matches.rb
|
@@ -26,32 +27,30 @@ files:
|
|
26
27
|
- lib/validation/rule/phone.rb
|
27
28
|
- lib/validation/rule/regular_expression.rb
|
28
29
|
- lib/validation/rule/uri.rb
|
30
|
+
- lib/validation/rule/uuid.rb
|
29
31
|
- lib/validation/validator.rb
|
30
32
|
- lib/validation/version.rb
|
31
|
-
- lib/validation.rb
|
32
|
-
- README.md
|
33
33
|
homepage: https://github.com/zombor/Validator
|
34
34
|
licenses: []
|
35
|
+
metadata: {}
|
35
36
|
post_install_message:
|
36
37
|
rdoc_options: []
|
37
38
|
require_paths:
|
38
39
|
- lib
|
39
40
|
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
41
41
|
requirements:
|
42
|
-
- -
|
42
|
+
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: '0'
|
45
45
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
-
none: false
|
47
46
|
requirements:
|
48
|
-
- -
|
47
|
+
- - ">="
|
49
48
|
- !ruby/object:Gem::Version
|
50
49
|
version: '0'
|
51
50
|
requirements: []
|
52
51
|
rubyforge_project:
|
53
|
-
rubygems_version:
|
52
|
+
rubygems_version: 2.2.2
|
54
53
|
signing_key:
|
55
|
-
specification_version:
|
54
|
+
specification_version: 4
|
56
55
|
summary: A standalone, generic object validator for ruby
|
57
56
|
test_files: []
|