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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b31bf98233e881ca1b0a1e7e21bd3a77bed7da9
4
- data.tar.gz: 6fc3e860a99157502c578c3dfe1e49e14e19c2fe
3
+ metadata.gz: 08af3476e39855609076f5f0258bebe71805abc2
4
+ data.tar.gz: 3a068b16cc74896589d36a182dfae61a53783c14
5
5
  SHA512:
6
- metadata.gz: f8279a01f3711d48cedb7a7d3e72c3db2800ec28418a9a4fbc61a54b029cfcbe1015e4a6b714388e2e946ded6123d4d107168fa3b36daa60c603266d6029935d
7
- data.tar.gz: c6b0f1cac4c9576186406fcbc634f9126ced9f87d2b1b7c5ffcb45683ec4a5fb5bbd955c57cb81a6fe4d1217e318e740b25e61c506603e583dd8fcb65b61172c
6
+ metadata.gz: 74388c59fc69f8c1c0aed7901e9aec6e993bc8024eeb7a7fc6fd5e59c6a36dbbb6b1e62169a73b0325533c8c8a66cca52a55626518e7a9cafc7582e705484c52
7
+ data.tar.gz: 188f7b55a14dc7eb68aa062c3419105ffecff87690f39835f0c74261b9cc2687732b4e0cc6d5b83c68ba8f0369ac611419ce20c1c7a71b90b94811b0a714e161
@@ -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 (only supports v4 at this time)
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
- if params[:version] == 'v4'
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
@@ -1,3 +1,3 @@
1
1
  module Validation
2
- VERSION = '1.0.2'
2
+ VERSION = '1.1.0'
3
3
  end
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.2
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-09-01 00:00:00.000000000 Z
11
+ date: 2015-10-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: