active_validation 1.0.0 → 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/.gitignore +1 -6
- data/.rspec +3 -3
- data/CODE_OF_CONDUCT.md +13 -0
- data/LICENSE.txt +17 -18
- data/README.md +100 -145
- data/active_validation.gemspec +4 -3
- data/bin/console +14 -0
- data/bin/rake +16 -0
- data/bin/setup +7 -0
- data/config/locales/en.yml +7 -8
- data/lib/active_validation.rb +4 -4
- data/lib/active_validation/matchers/{ensure_valid_latitude_format_of.rb → ensure_valid_coordinate_format_of.rb} +5 -5
- data/lib/active_validation/validators/coordinate_validator.rb +38 -0
- data/lib/active_validation/version.rb +1 -1
- metadata +11 -63
- data/lib/active_validation/matchers/ensure_valid_longitude_format_of.rb +0 -26
- data/lib/active_validation/validators/latitude_validator.rb +0 -9
- data/lib/active_validation/validators/longitude_validator.rb +0 -9
- data/spec/lib/alpha_numeric_validator_spec.rb +0 -91
- data/spec/lib/alpha_validator_spec.rb +0 -182
- data/spec/lib/base64_validator_spec.rb +0 -33
- data/spec/lib/boolean_validator_spec.rb +0 -35
- data/spec/lib/credit_card_validator_spec.rb +0 -686
- data/spec/lib/currency_validator_spec.rb +0 -63
- data/spec/lib/cusip_validator_spec.rb +0 -27
- data/spec/lib/email_validator_spec.rb +0 -109
- data/spec/lib/equality_validator_spec.rb +0 -334
- data/spec/lib/hex_validator_spec.rb +0 -73
- data/spec/lib/imei_validator_spec.rb +0 -41
- data/spec/lib/ip_validator_spec.rb +0 -33
- data/spec/lib/isbn_validator_spec.rb +0 -41
- data/spec/lib/isin_validator_spec.rb +0 -35
- data/spec/lib/latitude_validator_spec.rb +0 -31
- data/spec/lib/longitude_validator_spec.rb +0 -31
- data/spec/lib/mac_address_validator_spec.rb +0 -54
- data/spec/lib/name_validator_spec.rb +0 -39
- data/spec/lib/password_validator_spec.rb +0 -85
- data/spec/lib/phone_validator_spec.rb +0 -42
- data/spec/lib/sedol_validator_spec.rb +0 -31
- data/spec/lib/slug_validator_spec.rb +0 -41
- data/spec/lib/ssn_validator_spec.rb +0 -36
- data/spec/lib/url_validator_spec.rb +0 -106
- data/spec/lib/username_validator_spec.rb +0 -37
- data/spec/lib/uuid_validator_spec.rb +0 -157
- data/spec/spec_helper.rb +0 -12
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PhoneValidator do
|
4
|
-
|
5
|
-
context "has a valid value" do
|
6
|
-
let(:klass) do
|
7
|
-
Class.new do
|
8
|
-
include ActiveModel::Validations
|
9
|
-
attr_accessor :phone, :name
|
10
|
-
validates :phone, phone: true
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
subject { klass.new }
|
15
|
-
|
16
|
-
it { should allow_value("1234567").for(:phone) }
|
17
|
-
it { should allow_value("123-4567").for(:phone) }
|
18
|
-
it { should allow_value("123 4567").for(:phone) }
|
19
|
-
it { should allow_value("5551234567").for(:phone) }
|
20
|
-
it { should allow_value("555-123-4567").for(:phone) }
|
21
|
-
it { should allow_value("555 123 4567").for(:phone) }
|
22
|
-
it { should allow_value("(555) 123-4567").for(:phone) }
|
23
|
-
it { should allow_value("(555) 123-4567 ext 1234").for(:phone) }
|
24
|
-
it { should allow_value("(555) 123-4567 ext1234").for(:phone) }
|
25
|
-
it { should allow_value("(555) 123-4567 ext-1234").for(:phone) }
|
26
|
-
it { should allow_value("1-555-123-4567").for(:phone) }
|
27
|
-
it { should allow_value("+1-555-123-4567").for(:phone) }
|
28
|
-
it { should allow_value("+1 (555) 123-4567 ext-1234").for(:phone) }
|
29
|
-
|
30
|
-
it { should_not allow_value('').for(:phone) }
|
31
|
-
it { should_not allow_value(nil).for(:phone) }
|
32
|
-
it { should_not allow_value("123_4567").for(:phone) }
|
33
|
-
it { should_not allow_value("(555) 123-4567 ext:1234").for(:phone) }
|
34
|
-
it { should_not allow_value("(555) 123-4567 ext_1234").for(:phone) }
|
35
|
-
it { should_not allow_value("! \#$%\`|").for(:phone) }
|
36
|
-
it { should_not allow_value("<>@[]\`|").for(:phone) }
|
37
|
-
|
38
|
-
it { should ensure_valid_phone_format_of(:phone) }
|
39
|
-
it { should_not ensure_valid_phone_format_of(:name) }
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
@@ -1,31 +0,0 @@
|
|
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
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe SlugValidator do
|
4
|
-
|
5
|
-
context "has a valid value" do
|
6
|
-
let(:klass) do
|
7
|
-
Class.new do
|
8
|
-
include ActiveModel::Validations
|
9
|
-
attr_accessor :slug, :name
|
10
|
-
validates :slug, slug: true
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
subject { klass.new }
|
15
|
-
|
16
|
-
it { should allow_value("slug").for(:slug) }
|
17
|
-
it { should allow_value("slug1234").for(:slug) }
|
18
|
-
it { should allow_value("slug-word").for(:slug) }
|
19
|
-
it { should allow_value("slug-1234").for(:slug) }
|
20
|
-
|
21
|
-
it { should_not allow_value('').for(:slug) }
|
22
|
-
it { should_not allow_value(' ').for(:slug) }
|
23
|
-
it { should_not allow_value(nil).for(:slug) }
|
24
|
-
it { should_not allow_value(" slug").for(:slug) }
|
25
|
-
it { should_not allow_value(" slug ").for(:slug) }
|
26
|
-
it { should_not allow_value("slug ").for(:slug) }
|
27
|
-
it { should_not allow_value(" 1234").for(:slug) }
|
28
|
-
it { should_not allow_value(" 1234 ").for(:slug) }
|
29
|
-
it { should_not allow_value("1234 ").for(:slug) }
|
30
|
-
it { should_not allow_value("slug word").for(:slug) }
|
31
|
-
it { should_not allow_value("slug 1234").for(:slug) }
|
32
|
-
it { should_not allow_value("slug_word").for(:slug) }
|
33
|
-
it { should_not allow_value("slug_1234").for(:slug) }
|
34
|
-
it { should_not allow_value("! \#$%\`|").for(:slug) }
|
35
|
-
it { should_not allow_value("<>@[]\`|").for(:slug) }
|
36
|
-
|
37
|
-
it { should ensure_valid_slug_format_of(:slug) }
|
38
|
-
it { should_not ensure_valid_slug_format_of(:name) }
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe SsnValidator do
|
4
|
-
|
5
|
-
context "has a valid value" do
|
6
|
-
let(:klass) do
|
7
|
-
Class.new do
|
8
|
-
include ActiveModel::Validations
|
9
|
-
attr_accessor :ssn, :name
|
10
|
-
validates :ssn, ssn: true
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
subject { klass.new }
|
15
|
-
|
16
|
-
it { should allow_value("333-22-4444").for(:ssn) }
|
17
|
-
it { should allow_value("333224444").for(:ssn) }
|
18
|
-
|
19
|
-
it { should_not allow_value('').for(:ssn) }
|
20
|
-
it { should_not allow_value(' ').for(:ssn) }
|
21
|
-
it { should_not allow_value(nil).for(:ssn) }
|
22
|
-
it { should_not allow_value(" 333-22-4444").for(:ssn) }
|
23
|
-
it { should_not allow_value(" 333-22-4444 ").for(:ssn) }
|
24
|
-
it { should_not allow_value("333-22-4444 ").for(:ssn) }
|
25
|
-
it { should_not allow_value("333 22 4444").for(:ssn) }
|
26
|
-
it { should_not allow_value("333-22-444n").for(:ssn) }
|
27
|
-
it { should_not allow_value("333 22 4444").for(:ssn) }
|
28
|
-
it { should_not allow_value("3-2-4").for(:ssn) }
|
29
|
-
it { should_not allow_value("! \#$%\`|").for(:ssn) }
|
30
|
-
it { should_not allow_value("<>@[]\`|").for(:ssn) }
|
31
|
-
|
32
|
-
it { should ensure_valid_ssn_format_of(:ssn) }
|
33
|
-
it { should_not ensure_valid_ssn_format_of(:name) }
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
@@ -1,106 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe UrlValidator do
|
4
|
-
|
5
|
-
context "has valid format" do
|
6
|
-
let(:klass) do
|
7
|
-
Class.new do
|
8
|
-
include ActiveModel::Validations
|
9
|
-
attr_accessor :url, :name
|
10
|
-
validates :url, url: true
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
subject { klass.new }
|
15
|
-
|
16
|
-
it { should ensure_valid_url_format_of(:url) }
|
17
|
-
it { should_not ensure_valid_url_format_of(:name) }
|
18
|
-
|
19
|
-
it { should allow_value("http://example.com").for(:url) }
|
20
|
-
it { should allow_value("http://FooBar.cOm").for(:url) }
|
21
|
-
it { should allow_value("http://foo.bar.baz.com").for(:url) }
|
22
|
-
it { should allow_value("http://123.com").for(:url) }
|
23
|
-
it { should allow_value("http://www.example.ru").for(:url) }
|
24
|
-
it { should allow_value("http://user-example.co.uk").for(:url) }
|
25
|
-
it { should allow_value("https://example.com").for(:url) }
|
26
|
-
it { should allow_value("http://example.org/").for(:url) }
|
27
|
-
it { should allow_value("https://example.net/index.html").for(:url) }
|
28
|
-
it { should allow_value("http://example.net/login.php").for(:url) }
|
29
|
-
it { should allow_value("https://example.travel/").for(:url) }
|
30
|
-
it { should allow_value("http://example.aero").for(:url) }
|
31
|
-
it { should allow_value("http://example.aero?foo=bar").for(:url) }
|
32
|
-
|
33
|
-
it { should_not allow_value('').for(:url) }
|
34
|
-
it { should_not allow_value(' ').for(:url) }
|
35
|
-
it { should_not allow_value(nil).for(:url) }
|
36
|
-
it { should_not allow_value("example").for(:url) }
|
37
|
-
it { should_not allow_value("ftp://foo.bar.baz.com").for(:url) }
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "url must be in a specific domain" do
|
41
|
-
let(:klass) do
|
42
|
-
Class.new do
|
43
|
-
include ActiveModel::Validations
|
44
|
-
attr_accessor :url1, :url2
|
45
|
-
validates :url1, url: { domain: :org }
|
46
|
-
validates :url2, url: { domain: [:org, 'edu', 'Com.Au'] }
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
subject { klass.new }
|
51
|
-
|
52
|
-
it { should allow_value("http://example.org").for(:url1) }
|
53
|
-
it { should_not allow_value("http://example.com").for(:url1) }
|
54
|
-
|
55
|
-
it { should allow_value("http://example.org").for(:url2) }
|
56
|
-
it { should allow_value("http://example.edu").for(:url2) }
|
57
|
-
it { should allow_value("http://example.com.au").for(:url2) }
|
58
|
-
it { should allow_value("http://example.Com.Au").for(:url2) }
|
59
|
-
it { should_not allow_value("http://example.com").for(:url2) }
|
60
|
-
end
|
61
|
-
|
62
|
-
describe "url must be domain root" do
|
63
|
-
let(:klass) do
|
64
|
-
Class.new do
|
65
|
-
include ActiveModel::Validations
|
66
|
-
attr_accessor :url1, :url2
|
67
|
-
validates :url1, url: { root: true }
|
68
|
-
validates :url2, url: { root: false }
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
subject { klass.new }
|
73
|
-
|
74
|
-
it { should allow_value("http://example.org").for(:url1) }
|
75
|
-
it { should allow_value("http://example.org/").for(:url1) }
|
76
|
-
it { should_not allow_value("http://example.com/test").for(:url1) }
|
77
|
-
it { should_not allow_value("http://example.com/#fragment").for(:url1) }
|
78
|
-
it { should_not allow_value("http://example.com/?key=value").for(:url1) }
|
79
|
-
|
80
|
-
|
81
|
-
it { should allow_value("http://example.org").for(:url2) }
|
82
|
-
it { should allow_value("http://example.org/lorem").for(:url2) }
|
83
|
-
end
|
84
|
-
|
85
|
-
describe "url must have a specific scheme" do
|
86
|
-
let(:klass) do
|
87
|
-
Class.new do
|
88
|
-
include ActiveModel::Validations
|
89
|
-
attr_accessor :url1, :url2
|
90
|
-
validates :url1, url: { scheme: 'http' }
|
91
|
-
validates :url2, url: { scheme: ['HTTP', :https] }
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
subject { klass.new }
|
96
|
-
|
97
|
-
it { should allow_value("http://example.org").for(:url1) }
|
98
|
-
it { should_not allow_value("https://example.org").for(:url1) }
|
99
|
-
|
100
|
-
it { should allow_value("http://example.org").for(:url2) }
|
101
|
-
it { should allow_value("https://example.org").for(:url2) }
|
102
|
-
it { should allow_value("HTTPS://example.org").for(:url2) }
|
103
|
-
it { should_not allow_value("ftp://example.org").for(:url2) }
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe UsernameValidator do
|
4
|
-
|
5
|
-
context "has a valid value" do
|
6
|
-
let(:klass) do
|
7
|
-
Class.new do
|
8
|
-
include ActiveModel::Validations
|
9
|
-
attr_accessor :username, :name
|
10
|
-
validates :username, username: true
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
subject { klass.new }
|
15
|
-
|
16
|
-
it { should allow_value("username").for(:username) }
|
17
|
-
it { should allow_value("username123").for(:username) }
|
18
|
-
it { should allow_value("username_123").for(:username) }
|
19
|
-
it { should allow_value("username-123").for(:username) }
|
20
|
-
|
21
|
-
it { should_not allow_value('').for(:username) }
|
22
|
-
it { should_not allow_value(' ').for(:username) }
|
23
|
-
it { should_not allow_value(nil).for(:username) }
|
24
|
-
it { should_not allow_value("u").for(:username) }
|
25
|
-
it { should_not allow_value(" username").for(:username) }
|
26
|
-
it { should_not allow_value(" username ").for(:username) }
|
27
|
-
it { should_not allow_value("username ").for(:username) }
|
28
|
-
it { should_not allow_value("user name").for(:username) }
|
29
|
-
it { should_not allow_value("username-123456789").for(:username) }
|
30
|
-
it { should_not allow_value("! \#$%\`|").for(:username) }
|
31
|
-
it { should_not allow_value("<>@[]\`|").for(:username) }
|
32
|
-
|
33
|
-
it { should ensure_valid_username_format_of(:username) }
|
34
|
-
it { should_not ensure_valid_username_format_of(:name) }
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
@@ -1,157 +0,0 @@
|
|
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
|