valid 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/validation/rule/uuid.rb +10 -9
- data/lib/validation/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: 08af3476e39855609076f5f0258bebe71805abc2
|
4
|
+
data.tar.gz: 3a068b16cc74896589d36a182dfae61a53783c14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74388c59fc69f8c1c0aed7901e9aec6e993bc8024eeb7a7fc6fd5e59c6a36dbbb6b1e62169a73b0325533c8c8a66cca52a55626518e7a9cafc7582e705484c52
|
7
|
+
data.tar.gz: 188f7b55a14dc7eb68aa062c3419105ffecff87690f39835f0c74261b9cc2687732b4e0cc6d5b83c68ba8f0369ac611419ce20c1c7a71b90b94811b0a714e161
|
data/lib/validation/rule/uuid.rb
CHANGED
@@ -5,7 +5,9 @@ module Validation
|
|
5
5
|
class UnknownVersion < StandardError; end
|
6
6
|
# params can be any of the folowing:
|
7
7
|
#
|
8
|
-
# - :version - v4
|
8
|
+
# - :version - v4
|
9
|
+
# v5
|
10
|
+
# uuid (Any valid uuid)
|
9
11
|
#
|
10
12
|
# Example:
|
11
13
|
#
|
@@ -30,17 +32,16 @@ module Validation
|
|
30
32
|
|
31
33
|
private
|
32
34
|
|
35
|
+
VERSION_REGEX = {
|
36
|
+
'uuid' => /^[0-9A-F]{8}-[0-9A-F]{4}-[1-5][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
|
37
|
+
'v4' => /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
|
38
|
+
'v5' => /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,
|
39
|
+
}
|
40
|
+
|
33
41
|
def uuid_regex
|
34
|
-
|
35
|
-
uuid_v4_regex
|
36
|
-
else
|
37
|
-
raise UnknownVersion
|
38
|
-
end
|
42
|
+
VERSION_REGEX.fetch(params[:version]) { raise UnknownVersion }
|
39
43
|
end
|
40
44
|
|
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
45
|
end
|
45
46
|
end
|
46
47
|
end
|
data/lib/validation/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Bush
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|