flash_validators 1.1.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +258 -35
  3. data/config/locales/en.yml +66 -42
  4. data/lib/flash_validators/matchers/ensure_valid_alpha_format_of.rb +10 -2
  5. data/lib/flash_validators/matchers/ensure_valid_alpha_numeric_format_of.rb +10 -2
  6. data/lib/flash_validators/matchers/ensure_valid_base64_format_of.rb +26 -0
  7. data/lib/flash_validators/matchers/ensure_valid_boolean_format_of.rb +10 -2
  8. data/lib/flash_validators/matchers/ensure_valid_credit_card_format_of.rb +10 -2
  9. data/lib/flash_validators/matchers/ensure_valid_currency_format_of.rb +10 -2
  10. data/lib/flash_validators/matchers/ensure_valid_cusip_format_of.rb +26 -0
  11. data/lib/flash_validators/matchers/ensure_valid_email_format_of.rb +10 -2
  12. data/lib/flash_validators/matchers/ensure_valid_equality_matcher_of.rb +12 -2
  13. data/lib/flash_validators/matchers/ensure_valid_gtin_format_of.rb +26 -0
  14. data/lib/flash_validators/matchers/ensure_valid_hex_format_of.rb +10 -2
  15. data/lib/flash_validators/matchers/ensure_valid_imei_format_of.rb +10 -2
  16. data/lib/flash_validators/matchers/ensure_valid_ip_format_of.rb +10 -2
  17. data/lib/flash_validators/matchers/ensure_valid_isbn_format_of.rb +10 -2
  18. data/lib/flash_validators/matchers/ensure_valid_isin_format_of.rb +26 -0
  19. data/lib/flash_validators/matchers/ensure_valid_latitude_format_of.rb +10 -2
  20. data/lib/flash_validators/matchers/ensure_valid_longitude_format_of.rb +10 -2
  21. data/lib/flash_validators/matchers/ensure_valid_mac_address_format_of.rb +10 -2
  22. data/lib/flash_validators/matchers/ensure_valid_name_format_of.rb +10 -2
  23. data/lib/flash_validators/matchers/ensure_valid_password_format_of.rb +10 -2
  24. data/lib/flash_validators/matchers/ensure_valid_phone_format_of.rb +10 -2
  25. data/lib/flash_validators/matchers/ensure_valid_sedol_format_of.rb +26 -0
  26. data/lib/flash_validators/matchers/ensure_valid_slug_format_of.rb +10 -2
  27. data/lib/flash_validators/matchers/ensure_valid_ssn_format_of.rb +10 -2
  28. data/lib/flash_validators/matchers/ensure_valid_url_format_of.rb +10 -2
  29. data/lib/flash_validators/matchers/ensure_valid_username_format_of.rb +10 -2
  30. data/lib/flash_validators/matchers/ensure_valid_uuid_format_of.rb +26 -0
  31. data/lib/flash_validators/validators/alpha_numeric_validator.rb +21 -7
  32. data/lib/flash_validators/validators/alpha_validator.rb +22 -10
  33. data/lib/flash_validators/validators/base64_validator.rb +9 -0
  34. data/lib/flash_validators/validators/credit_card_validator.rb +123 -15
  35. data/lib/flash_validators/validators/currency_validator.rb +13 -7
  36. data/lib/flash_validators/validators/cusip_validator.rb +33 -0
  37. data/lib/flash_validators/validators/email_validator.rb +7 -7
  38. data/lib/flash_validators/validators/equality_validator.rb +7 -7
  39. data/lib/flash_validators/validators/gtin_validator.rb +59 -0
  40. data/lib/flash_validators/validators/hex_validator.rb +1 -1
  41. data/lib/flash_validators/validators/imei_validator.rb +8 -8
  42. data/lib/flash_validators/validators/isbn_validator.rb +9 -16
  43. data/lib/flash_validators/validators/isin_validator.rb +38 -0
  44. data/lib/flash_validators/validators/mac_address_validator.rb +10 -10
  45. data/lib/flash_validators/validators/password_validator.rb +13 -7
  46. data/lib/flash_validators/validators/sedol_validator.rb +32 -0
  47. data/lib/flash_validators/validators/url_validator.rb +13 -13
  48. data/lib/flash_validators/validators/uuid_validator.rb +28 -0
  49. data/lib/flash_validators/version.rb +1 -1
  50. data/lib/flash_validators.rb +12 -0
  51. data/spec/lib/alpha_numeric_validator_spec.rb +31 -1
  52. data/spec/lib/alpha_validator_spec.rb +68 -6
  53. data/spec/lib/base64_validator_spec.rb +33 -0
  54. data/spec/lib/credit_card_validator_spec.rb +495 -125
  55. data/spec/lib/cusip_validator_spec.rb +27 -0
  56. data/spec/lib/gtin_validator_spec.rb +101 -0
  57. data/spec/lib/hex_validator_spec.rb +20 -0
  58. data/spec/lib/isin_validator_spec.rb +35 -0
  59. data/spec/lib/sedol_validator_spec.rb +31 -0
  60. data/spec/lib/uuid_validator_spec.rb +157 -0
  61. metadata +26 -2
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe CusipValidator do
4
+
5
+ context "has a valid value" do
6
+ let(:klass) do
7
+ Class.new do
8
+ include ActiveModel::Validations
9
+ attr_accessor :code, :name
10
+ validates :code, cusip: true
11
+ end
12
+ end
13
+
14
+ subject { klass.new }
15
+
16
+ it { should allow_value("125509BG3").for(:code) }
17
+
18
+ it { should_not allow_value('').for(:code) }
19
+ it { should_not allow_value(' ').for(:code) }
20
+ it { should_not allow_value(nil).for(:code) }
21
+ it { should_not allow_value("12345678AB").for(:code) }
22
+
23
+ it { should ensure_valid_cusip_format_of(:code) }
24
+ it { should_not ensure_valid_cusip_format_of(:name) }
25
+ end
26
+
27
+ end
@@ -0,0 +1,101 @@
1
+ require 'spec_helper'
2
+
3
+ describe GtinValidator do
4
+
5
+ context "has a valid value" do
6
+ let(:klass) do
7
+ Class.new do
8
+ include ActiveModel::Validations
9
+ attr_accessor :code, :name
10
+ validates :code, gtin: true
11
+ end
12
+ end
13
+
14
+ subject { klass.new }
15
+
16
+ it { should allow_value("73513537").for(:code) }
17
+ it { should allow_value("4006381333931").for(:code) }
18
+ it { should allow_value("9780471117094").for(:code) }
19
+ it { should allow_value("73 51353 7").for(:code) }
20
+ it { should allow_value("4 006381 33393 1").for(:code) }
21
+ it { should allow_value("97 804711 17094").for(:code) }
22
+
23
+ it { should_not allow_value('').for(:code) }
24
+ it { should_not allow_value(' ').for(:code) }
25
+ it { should_not allow_value(nil).for(:code) }
26
+ it { should_not allow_value("73513536").for(:code) }
27
+ it { should_not allow_value("97804711170941").for(:code) }
28
+ it { should_not allow_value("73 51353 6").for(:code) }
29
+ it { should_not allow_value("97 804711 17094 1").for(:code) }
30
+ it { should_not allow_value("! \#$%\`|").for(:code) }
31
+ it { should_not allow_value("<>@[]\`|").for(:code) }
32
+
33
+ it { should ensure_valid_gtin_format_of(:code) }
34
+ it { should_not ensure_valid_gtin_format_of(:name) }
35
+ end
36
+
37
+ context "with :strict option has a valid value" do
38
+ let(:klass) do
39
+ Class.new do
40
+ include ActiveModel::Validations
41
+ attr_accessor :code, :name
42
+ validates :code, gtin: { strict: true }
43
+ end
44
+ end
45
+
46
+ subject { klass.new }
47
+
48
+ it { should allow_value("73513537").for(:code) }
49
+ it { should allow_value("4006381333931").for(:code) }
50
+ it { should allow_value("9780471117094").for(:code) }
51
+
52
+ it { should_not allow_value('').for(:code) }
53
+ it { should_not allow_value(' ').for(:code) }
54
+ it { should_not allow_value(nil).for(:code) }
55
+ it { should_not allow_value("73513536").for(:code) }
56
+ it { should_not allow_value("97804711170941").for(:code) }
57
+ it { should_not allow_value("73 51353 6").for(:code) }
58
+ it { should_not allow_value("73 51353 7").for(:code) }
59
+ it { should_not allow_value("4 006381 33393 1").for(:code) }
60
+ it { should_not allow_value("97 804711 17094 1").for(:code) }
61
+ it { should_not allow_value("97 804711 17094").for(:code) }
62
+ it { should_not allow_value("! \#$%\`|").for(:code) }
63
+ it { should_not allow_value("<>@[]\`|").for(:code) }
64
+
65
+ it { should ensure_valid_gtin_format_of(:code) }
66
+ it { should_not ensure_valid_gtin_format_of(:name) }
67
+ end
68
+
69
+ context "with format: :ean_8 and :strict options has a valid value" do
70
+ let(:klass) do
71
+ Class.new do
72
+ include ActiveModel::Validations
73
+ attr_accessor :code, :name
74
+ validates :code, gtin: { format: :ean_8, strict: true }
75
+ end
76
+ end
77
+
78
+ subject { klass.new }
79
+
80
+ it { should allow_value("73513537").for(:code) }
81
+
82
+ it { should_not allow_value('').for(:code) }
83
+ it { should_not allow_value(' ').for(:code) }
84
+ it { should_not allow_value(nil).for(:code) }
85
+ it { should_not allow_value("73513536").for(:code) }
86
+ it { should_not allow_value("4006381333931").for(:code) }
87
+ it { should_not allow_value("9780471117094").for(:code) }
88
+ it { should_not allow_value("97804711170941").for(:code) }
89
+ it { should_not allow_value("73 51353 6").for(:code) }
90
+ it { should_not allow_value("73 51353 7").for(:code) }
91
+ it { should_not allow_value("4 006381 33393 1").for(:code) }
92
+ it { should_not allow_value("97 804711 17094 1").for(:code) }
93
+ it { should_not allow_value("97 804711 17094").for(:code) }
94
+ it { should_not allow_value("! \#$%\`|").for(:code) }
95
+ it { should_not allow_value("<>@[]\`|").for(:code) }
96
+
97
+ it { should ensure_valid_gtin_format_of(:code) }
98
+ it { should_not ensure_valid_gtin_format_of(:name) }
99
+ end
100
+
101
+ end
@@ -14,17 +14,25 @@ describe HexValidator do
14
14
  subject { klass.new }
15
15
 
16
16
  it { should allow_value("#aaa").for(:color) }
17
+ it { should allow_value("#AAA").for(:color) }
17
18
  it { should allow_value("#aaaaaa").for(:color) }
19
+ it { should allow_value("#AAAAAA").for(:color) }
18
20
  it { should allow_value("#999").for(:color) }
19
21
  it { should allow_value("#999999").for(:color) }
20
22
  it { should allow_value("#a9a").for(:color) }
23
+ it { should allow_value("#A9A").for(:color) }
21
24
  it { should allow_value("#a9a9a9").for(:color) }
25
+ it { should allow_value("#A9A9A9").for(:color) }
22
26
  it { should allow_value("aaa").for(:color) }
27
+ it { should allow_value("AAA").for(:color) }
23
28
  it { should allow_value("aaaaaa").for(:color) }
29
+ it { should allow_value("AAAAAA").for(:color) }
24
30
  it { should allow_value("999").for(:color) }
25
31
  it { should allow_value("999999").for(:color) }
26
32
  it { should allow_value("a9a").for(:color) }
33
+ it { should allow_value("A9A").for(:color) }
27
34
  it { should allow_value("a9a9a9").for(:color) }
35
+ it { should allow_value("A9A9A9").for(:color) }
28
36
 
29
37
  it { should_not allow_value('').for(:color) }
30
38
  it { should_not allow_value(' ').for(:color) }
@@ -32,17 +40,29 @@ describe HexValidator do
32
40
  it { should_not allow_value("#").for(:color) }
33
41
  it { should_not allow_value("#9").for(:color) }
34
42
  it { should_not allow_value("#9a").for(:color) }
43
+ it { should_not allow_value("#9A").for(:color) }
35
44
  it { should_not allow_value("#hhh").for(:color) }
45
+ it { should_not allow_value("#HHH").for(:color) }
36
46
  it { should_not allow_value("#9h9").for(:color) }
47
+ it { should_not allow_value("#9H9").for(:color) }
37
48
  it { should_not allow_value("#9a9a").for(:color) }
49
+ it { should_not allow_value("#9A9A").for(:color) }
38
50
  it { should_not allow_value("#9a9a9").for(:color) }
51
+ it { should_not allow_value("#9A9A9").for(:color) }
39
52
  it { should_not allow_value("#9a9a9a9").for(:color) }
53
+ it { should_not allow_value("#9A9A9A9").for(:color) }
40
54
  it { should_not allow_value(" #9a9").for(:color) }
55
+ it { should_not allow_value(" #9A9").for(:color) }
41
56
  it { should_not allow_value(" #9a9 ").for(:color) }
57
+ it { should_not allow_value(" #9A9 ").for(:color) }
42
58
  it { should_not allow_value("#9a9 ").for(:color) }
59
+ it { should_not allow_value("#9A9 ").for(:color) }
43
60
  it { should_not allow_value(" 9a9").for(:color) }
61
+ it { should_not allow_value(" 9A9").for(:color) }
44
62
  it { should_not allow_value(" 9a9 ").for(:color) }
63
+ it { should_not allow_value(" 9A9 ").for(:color) }
45
64
  it { should_not allow_value("9a9 ").for(:color) }
65
+ it { should_not allow_value("9A9 ").for(:color) }
46
66
  it { should_not allow_value("! \#$%\`|").for(:color) }
47
67
  it { should_not allow_value("<>@[]\`|").for(:color) }
48
68
 
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe IsinValidator do
4
+
5
+ context "has a valid value" do
6
+ let(:klass) do
7
+ Class.new do
8
+ include ActiveModel::Validations
9
+ attr_accessor :isin, :name
10
+ validates :isin, isin: true
11
+ end
12
+ end
13
+
14
+ subject { klass.new }
15
+
16
+ it { should allow_value("US0378331005").for(:isin) }
17
+ it { should allow_value("AU0000XVGZA3").for(:isin) }
18
+
19
+ it { should_not allow_value('').for(:isin) }
20
+ it { should_not allow_value(' ').for(:isin) }
21
+ it { should_not allow_value(nil).for(:isin) }
22
+ it { should_not allow_value("US03783310055").for(:isin) }
23
+ #it { should_not allow_value("US0378331004").for(:isin) }
24
+ it { should_not allow_value("US037833100").for(:isin) }
25
+ it { should_not allow_value("US03783315").for(:isin) }
26
+ it { should_not allow_value("AA0000XVGZA3").for(:isin) }
27
+ it { should_not allow_value("120378331004").for(:isin) }
28
+ it { should_not allow_value("! \#$%\`|").for(:isin) }
29
+ it { should_not allow_value("<>@[]\`|").for(:isin) }
30
+
31
+ it { should ensure_valid_isin_format_of(:isin) }
32
+ it { should_not ensure_valid_isin_format_of(:name) }
33
+ end
34
+
35
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe SedolValidator do
4
+
5
+ context "has a valid value" do
6
+ let(:klass) do
7
+ Class.new do
8
+ include ActiveModel::Validations
9
+ attr_accessor :sedol, :name
10
+ validates :sedol, sedol: true
11
+ end
12
+ end
13
+
14
+ subject { klass.new }
15
+
16
+ it { should allow_value("B0WNLY7").for(:sedol) }
17
+
18
+ it { should_not allow_value('').for(:sedol) }
19
+ it { should_not allow_value(' ').for(:sedol) }
20
+ it { should_not allow_value(nil).for(:sedol) }
21
+ it { should_not allow_value("B0WNL").for(:sedol) }
22
+ it { should_not allow_value("B0WNLY").for(:sedol) }
23
+ it { should_not allow_value("B0WNLY77").for(:sedol) }
24
+ it { should_not allow_value("! \#$%\`|").for(:sedol) }
25
+ it { should_not allow_value("<>@[]\`|").for(:sedol) }
26
+
27
+ it { should ensure_valid_sedol_format_of(:sedol) }
28
+ it { should_not ensure_valid_sedol_format_of(:name) }
29
+ end
30
+
31
+ end
@@ -0,0 +1,157 @@
1
+ require 'spec_helper'
2
+
3
+ describe UuidValidator do
4
+
5
+ context "has a valid value" do
6
+ let(:klass) do
7
+ Class.new do
8
+ include ActiveModel::Validations
9
+ attr_accessor :uuid, :name
10
+ validates :uuid, uuid: true
11
+ end
12
+ end
13
+
14
+ subject { klass.new }
15
+
16
+ it { should allow_value("6fa459ea-ee8a-3ca4-894e-db77e160355e").for(:uuid) }
17
+ it { should allow_value("16fd2706-8baf-433b-82eb-8c7fada847da").for(:uuid) }
18
+ it { should allow_value("886313e1-3b8a-5372-9b90-0c9aee199e5d").for(:uuid) }
19
+ it { should allow_value("a8098c1a-f86e-11da-bd1a-00112444be1e").for(:uuid) }
20
+
21
+ it { should_not allow_value('').for(:uuid) }
22
+ it { should_not allow_value(' ').for(:uuid) }
23
+ it { should_not allow_value(nil).for(:uuid) }
24
+ it { should_not allow_value("6fa459ea-ee8a-3ca4-894e-db77e160355e1").for(:uuid) }
25
+ it { should_not allow_value("16fd2706-8baf-433b-82eb-8c7fada847da1").for(:uuid) }
26
+ it { should_not allow_value("886313e1-3b8a-5372-9b90-0c9aee199e5d1").for(:uuid) }
27
+ it { should_not allow_value("a8098c1a-f86e-11da-bd1a-00112444be1e1").for(:uuid) }
28
+ it { should_not allow_value("6fa459ea-ee8a-3ca4-894e-db77e160355").for(:uuid) }
29
+ it { should_not allow_value("16fd2706-8baf-433b-82eb-8c7fada847d").for(:uuid) }
30
+ it { should_not allow_value("886313e1-3b8a-5372-9b90-0c9aee199e5").for(:uuid) }
31
+ it { should_not allow_value("a8098c1a-f86e-11da-bd1a-00112444be1").for(:uuid) }
32
+ it { should_not allow_value("6fa459eaee8a3ca4894edb77e160355e").for(:uuid) }
33
+ it { should_not allow_value("16fd27068baf433b82eb8c7fada847da").for(:uuid) }
34
+ it { should_not allow_value("886313e13b8a53729b900c9aee199e5d").for(:uuid) }
35
+ it { should_not allow_value("a8098c1af86e11dabd1a00112444be1e").for(:uuid) }
36
+ it { should_not allow_value("! \#$%\`|").for(:uuid) }
37
+ it { should_not allow_value("<>@[]\`|").for(:uuid) }
38
+
39
+ it { should ensure_valid_uuid_format_of(:uuid) }
40
+ it { should_not ensure_valid_uuid_format_of(:name) }
41
+ end
42
+
43
+ context "with version: 3 option has a valid value" do
44
+ let(:klass) do
45
+ Class.new do
46
+ include ActiveModel::Validations
47
+ attr_accessor :uuid, :name
48
+ validates :uuid, uuid: { version: 3 }
49
+ end
50
+ end
51
+
52
+ subject { klass.new }
53
+
54
+ it { should allow_value("6fa459ea-ee8a-3ca4-894e-db77e160355e").for(:uuid) }
55
+
56
+ it { should_not allow_value('').for(:uuid) }
57
+ it { should_not allow_value(' ').for(:uuid) }
58
+ it { should_not allow_value(nil).for(:uuid) }
59
+ it { should_not allow_value("16fd2706-8baf-433b-82eb-8c7fada847da").for(:uuid) }
60
+ it { should_not allow_value("886313e1-3b8a-5372-9b90-0c9aee199e5d").for(:uuid) }
61
+ it { should_not allow_value("a8098c1a-f86e-11da-bd1a-00112444be1e").for(:uuid) }
62
+ it { should_not allow_value("6fa459ea-ee8a-3ca4-894e-db77e160355e1").for(:uuid) }
63
+ it { should_not allow_value("16fd2706-8baf-433b-82eb-8c7fada847da1").for(:uuid) }
64
+ it { should_not allow_value("886313e1-3b8a-5372-9b90-0c9aee199e5d1").for(:uuid) }
65
+ it { should_not allow_value("a8098c1a-f86e-11da-bd1a-00112444be1e1").for(:uuid) }
66
+ it { should_not allow_value("6fa459ea-ee8a-3ca4-894e-db77e160355").for(:uuid) }
67
+ it { should_not allow_value("16fd2706-8baf-433b-82eb-8c7fada847d").for(:uuid) }
68
+ it { should_not allow_value("886313e1-3b8a-5372-9b90-0c9aee199e5").for(:uuid) }
69
+ it { should_not allow_value("a8098c1a-f86e-11da-bd1a-00112444be1").for(:uuid) }
70
+ it { should_not allow_value("6fa459eaee8a3ca4894edb77e160355e").for(:uuid) }
71
+ it { should_not allow_value("16fd27068baf433b82eb8c7fada847da").for(:uuid) }
72
+ it { should_not allow_value("886313e13b8a53729b900c9aee199e5d").for(:uuid) }
73
+ it { should_not allow_value("a8098c1af86e11dabd1a00112444be1e").for(:uuid) }
74
+ it { should_not allow_value("! \#$%\`|").for(:uuid) }
75
+ it { should_not allow_value("<>@[]\`|").for(:uuid) }
76
+
77
+ it { should ensure_valid_uuid_format_of(:uuid) }
78
+ it { should_not ensure_valid_uuid_format_of(:name) }
79
+ end
80
+
81
+ context "with version: 4 option has a valid value" do
82
+ let(:klass) do
83
+ Class.new do
84
+ include ActiveModel::Validations
85
+ attr_accessor :uuid, :name
86
+ validates :uuid, uuid: { version: 4 }
87
+ end
88
+ end
89
+
90
+ subject { klass.new }
91
+
92
+ it { should allow_value("16fd2706-8baf-433b-82eb-8c7fada847da").for(:uuid) }
93
+
94
+ it { should_not allow_value('').for(:uuid) }
95
+ it { should_not allow_value(' ').for(:uuid) }
96
+ it { should_not allow_value(nil).for(:uuid) }
97
+ it { should_not allow_value("6fa459ea-ee8a-3ca4-894e-db77e160355e").for(:uuid) }
98
+ it { should_not allow_value("886313e1-3b8a-5372-9b90-0c9aee199e5d").for(:uuid) }
99
+ it { should_not allow_value("a8098c1a-f86e-11da-bd1a-00112444be1e").for(:uuid) }
100
+ it { should_not allow_value("6fa459ea-ee8a-3ca4-894e-db77e160355e1").for(:uuid) }
101
+ it { should_not allow_value("16fd2706-8baf-433b-82eb-8c7fada847da1").for(:uuid) }
102
+ it { should_not allow_value("886313e1-3b8a-5372-9b90-0c9aee199e5d1").for(:uuid) }
103
+ it { should_not allow_value("a8098c1a-f86e-11da-bd1a-00112444be1e1").for(:uuid) }
104
+ it { should_not allow_value("6fa459ea-ee8a-3ca4-894e-db77e160355").for(:uuid) }
105
+ it { should_not allow_value("16fd2706-8baf-433b-82eb-8c7fada847d").for(:uuid) }
106
+ it { should_not allow_value("886313e1-3b8a-5372-9b90-0c9aee199e5").for(:uuid) }
107
+ it { should_not allow_value("a8098c1a-f86e-11da-bd1a-00112444be1").for(:uuid) }
108
+ it { should_not allow_value("6fa459eaee8a3ca4894edb77e160355e").for(:uuid) }
109
+ it { should_not allow_value("16fd27068baf433b82eb8c7fada847da").for(:uuid) }
110
+ it { should_not allow_value("886313e13b8a53729b900c9aee199e5d").for(:uuid) }
111
+ it { should_not allow_value("a8098c1af86e11dabd1a00112444be1e").for(:uuid) }
112
+ it { should_not allow_value("! \#$%\`|").for(:uuid) }
113
+ it { should_not allow_value("<>@[]\`|").for(:uuid) }
114
+
115
+ it { should ensure_valid_uuid_format_of(:uuid) }
116
+ it { should_not ensure_valid_uuid_format_of(:name) }
117
+ end
118
+
119
+ context "with version: 5 option has a valid value" do
120
+ let(:klass) do
121
+ Class.new do
122
+ include ActiveModel::Validations
123
+ attr_accessor :uuid, :name
124
+ validates :uuid, uuid: { version: 5 }
125
+ end
126
+ end
127
+
128
+ subject { klass.new }
129
+
130
+ it { should allow_value("886313e1-3b8a-5372-9b90-0c9aee199e5d").for(:uuid) }
131
+
132
+ it { should_not allow_value('').for(:uuid) }
133
+ it { should_not allow_value(' ').for(:uuid) }
134
+ it { should_not allow_value(nil).for(:uuid) }
135
+ it { should_not allow_value("6fa459ea-ee8a-3ca4-894e-db77e160355e").for(:uuid) }
136
+ it { should_not allow_value("16fd2706-8baf-433b-82eb-8c7fada847da").for(:uuid) }
137
+ it { should_not allow_value("a8098c1a-f86e-11da-bd1a-00112444be1e").for(:uuid) }
138
+ it { should_not allow_value("6fa459ea-ee8a-3ca4-894e-db77e160355e1").for(:uuid) }
139
+ it { should_not allow_value("16fd2706-8baf-433b-82eb-8c7fada847da1").for(:uuid) }
140
+ it { should_not allow_value("886313e1-3b8a-5372-9b90-0c9aee199e5d1").for(:uuid) }
141
+ it { should_not allow_value("a8098c1a-f86e-11da-bd1a-00112444be1e1").for(:uuid) }
142
+ it { should_not allow_value("6fa459ea-ee8a-3ca4-894e-db77e160355").for(:uuid) }
143
+ it { should_not allow_value("16fd2706-8baf-433b-82eb-8c7fada847d").for(:uuid) }
144
+ it { should_not allow_value("886313e1-3b8a-5372-9b90-0c9aee199e5").for(:uuid) }
145
+ it { should_not allow_value("a8098c1a-f86e-11da-bd1a-00112444be1").for(:uuid) }
146
+ it { should_not allow_value("6fa459eaee8a3ca4894edb77e160355e").for(:uuid) }
147
+ it { should_not allow_value("16fd27068baf433b82eb8c7fada847da").for(:uuid) }
148
+ it { should_not allow_value("886313e13b8a53729b900c9aee199e5d").for(:uuid) }
149
+ it { should_not allow_value("a8098c1af86e11dabd1a00112444be1e").for(:uuid) }
150
+ it { should_not allow_value("! \#$%\`|").for(:uuid) }
151
+ it { should_not allow_value("<>@[]\`|").for(:uuid) }
152
+
153
+ it { should ensure_valid_uuid_format_of(:uuid) }
154
+ it { should_not ensure_valid_uuid_format_of(:name) }
155
+ end
156
+
157
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flash_validators
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-29 00:00:00.000000000 Z
11
+ date: 2014-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -128,68 +128,86 @@ files:
128
128
  - lib/flash_validators.rb
129
129
  - lib/flash_validators/matchers/ensure_valid_alpha_format_of.rb
130
130
  - lib/flash_validators/matchers/ensure_valid_alpha_numeric_format_of.rb
131
+ - lib/flash_validators/matchers/ensure_valid_base64_format_of.rb
131
132
  - lib/flash_validators/matchers/ensure_valid_boolean_format_of.rb
132
133
  - lib/flash_validators/matchers/ensure_valid_credit_card_format_of.rb
133
134
  - lib/flash_validators/matchers/ensure_valid_currency_format_of.rb
135
+ - lib/flash_validators/matchers/ensure_valid_cusip_format_of.rb
134
136
  - lib/flash_validators/matchers/ensure_valid_email_format_of.rb
135
137
  - lib/flash_validators/matchers/ensure_valid_equality_matcher_of.rb
138
+ - lib/flash_validators/matchers/ensure_valid_gtin_format_of.rb
136
139
  - lib/flash_validators/matchers/ensure_valid_hex_format_of.rb
137
140
  - lib/flash_validators/matchers/ensure_valid_imei_format_of.rb
138
141
  - lib/flash_validators/matchers/ensure_valid_ip_format_of.rb
139
142
  - lib/flash_validators/matchers/ensure_valid_isbn_format_of.rb
143
+ - lib/flash_validators/matchers/ensure_valid_isin_format_of.rb
140
144
  - lib/flash_validators/matchers/ensure_valid_latitude_format_of.rb
141
145
  - lib/flash_validators/matchers/ensure_valid_longitude_format_of.rb
142
146
  - lib/flash_validators/matchers/ensure_valid_mac_address_format_of.rb
143
147
  - lib/flash_validators/matchers/ensure_valid_name_format_of.rb
144
148
  - lib/flash_validators/matchers/ensure_valid_password_format_of.rb
145
149
  - lib/flash_validators/matchers/ensure_valid_phone_format_of.rb
150
+ - lib/flash_validators/matchers/ensure_valid_sedol_format_of.rb
146
151
  - lib/flash_validators/matchers/ensure_valid_slug_format_of.rb
147
152
  - lib/flash_validators/matchers/ensure_valid_ssn_format_of.rb
148
153
  - lib/flash_validators/matchers/ensure_valid_url_format_of.rb
149
154
  - lib/flash_validators/matchers/ensure_valid_username_format_of.rb
155
+ - lib/flash_validators/matchers/ensure_valid_uuid_format_of.rb
150
156
  - lib/flash_validators/validators/alpha_numeric_validator.rb
151
157
  - lib/flash_validators/validators/alpha_validator.rb
158
+ - lib/flash_validators/validators/base64_validator.rb
152
159
  - lib/flash_validators/validators/boolean_validator.rb
153
160
  - lib/flash_validators/validators/credit_card_validator.rb
154
161
  - lib/flash_validators/validators/currency_validator.rb
162
+ - lib/flash_validators/validators/cusip_validator.rb
155
163
  - lib/flash_validators/validators/email_validator.rb
156
164
  - lib/flash_validators/validators/equality_validator.rb
165
+ - lib/flash_validators/validators/gtin_validator.rb
157
166
  - lib/flash_validators/validators/hex_validator.rb
158
167
  - lib/flash_validators/validators/imei_validator.rb
159
168
  - lib/flash_validators/validators/ip_validator.rb
160
169
  - lib/flash_validators/validators/isbn_validator.rb
170
+ - lib/flash_validators/validators/isin_validator.rb
161
171
  - lib/flash_validators/validators/latitude_validator.rb
162
172
  - lib/flash_validators/validators/longitude_validator.rb
163
173
  - lib/flash_validators/validators/mac_address_validator.rb
164
174
  - lib/flash_validators/validators/name_validator.rb
165
175
  - lib/flash_validators/validators/password_validator.rb
166
176
  - lib/flash_validators/validators/phone_validator.rb
177
+ - lib/flash_validators/validators/sedol_validator.rb
167
178
  - lib/flash_validators/validators/slug_validator.rb
168
179
  - lib/flash_validators/validators/ssn_validator.rb
169
180
  - lib/flash_validators/validators/url_validator.rb
170
181
  - lib/flash_validators/validators/username_validator.rb
182
+ - lib/flash_validators/validators/uuid_validator.rb
171
183
  - lib/flash_validators/version.rb
172
184
  - spec/lib/alpha_numeric_validator_spec.rb
173
185
  - spec/lib/alpha_validator_spec.rb
186
+ - spec/lib/base64_validator_spec.rb
174
187
  - spec/lib/boolean_validator_spec.rb
175
188
  - spec/lib/credit_card_validator_spec.rb
176
189
  - spec/lib/currency_validator_spec.rb
190
+ - spec/lib/cusip_validator_spec.rb
177
191
  - spec/lib/email_validator_spec.rb
178
192
  - spec/lib/equality_validator_spec.rb
193
+ - spec/lib/gtin_validator_spec.rb
179
194
  - spec/lib/hex_validator_spec.rb
180
195
  - spec/lib/imei_validator_spec.rb
181
196
  - spec/lib/ip_validator_spec.rb
182
197
  - spec/lib/isbn_validator_spec.rb
198
+ - spec/lib/isin_validator_spec.rb
183
199
  - spec/lib/latitude_validator_spec.rb
184
200
  - spec/lib/longitude_validator_spec.rb
185
201
  - spec/lib/mac_address_validator_spec.rb
186
202
  - spec/lib/name_validator_spec.rb
187
203
  - spec/lib/password_validator_spec.rb
188
204
  - spec/lib/phone_validator_spec.rb
205
+ - spec/lib/sedol_validator_spec.rb
189
206
  - spec/lib/slug_validator_spec.rb
190
207
  - spec/lib/ssn_validator_spec.rb
191
208
  - spec/lib/url_validator_spec.rb
192
209
  - spec/lib/username_validator_spec.rb
210
+ - spec/lib/uuid_validator_spec.rb
193
211
  - spec/spec_helper.rb
194
212
  homepage: https://github.com/drexed/flash_validators
195
213
  licenses:
@@ -218,23 +236,29 @@ summary: Gem for commonly used model validators.
218
236
  test_files:
219
237
  - spec/lib/alpha_numeric_validator_spec.rb
220
238
  - spec/lib/alpha_validator_spec.rb
239
+ - spec/lib/base64_validator_spec.rb
221
240
  - spec/lib/boolean_validator_spec.rb
222
241
  - spec/lib/credit_card_validator_spec.rb
223
242
  - spec/lib/currency_validator_spec.rb
243
+ - spec/lib/cusip_validator_spec.rb
224
244
  - spec/lib/email_validator_spec.rb
225
245
  - spec/lib/equality_validator_spec.rb
246
+ - spec/lib/gtin_validator_spec.rb
226
247
  - spec/lib/hex_validator_spec.rb
227
248
  - spec/lib/imei_validator_spec.rb
228
249
  - spec/lib/ip_validator_spec.rb
229
250
  - spec/lib/isbn_validator_spec.rb
251
+ - spec/lib/isin_validator_spec.rb
230
252
  - spec/lib/latitude_validator_spec.rb
231
253
  - spec/lib/longitude_validator_spec.rb
232
254
  - spec/lib/mac_address_validator_spec.rb
233
255
  - spec/lib/name_validator_spec.rb
234
256
  - spec/lib/password_validator_spec.rb
235
257
  - spec/lib/phone_validator_spec.rb
258
+ - spec/lib/sedol_validator_spec.rb
236
259
  - spec/lib/slug_validator_spec.rb
237
260
  - spec/lib/ssn_validator_spec.rb
238
261
  - spec/lib/url_validator_spec.rb
239
262
  - spec/lib/username_validator_spec.rb
263
+ - spec/lib/uuid_validator_spec.rb
240
264
  - spec/spec_helper.rb