active_validation 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,73 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe HexValidator do
|
4
|
-
|
5
|
-
context "has a valid value" do
|
6
|
-
let(:klass) do
|
7
|
-
Class.new do
|
8
|
-
include ActiveModel::Validations
|
9
|
-
attr_accessor :color, :name
|
10
|
-
validates :color, hex: true
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
subject { klass.new }
|
15
|
-
|
16
|
-
it { should allow_value("#aaa").for(:color) }
|
17
|
-
it { should allow_value("#AAA").for(:color) }
|
18
|
-
it { should allow_value("#aaaaaa").for(:color) }
|
19
|
-
it { should allow_value("#AAAAAA").for(:color) }
|
20
|
-
it { should allow_value("#999").for(:color) }
|
21
|
-
it { should allow_value("#999999").for(:color) }
|
22
|
-
it { should allow_value("#a9a").for(:color) }
|
23
|
-
it { should allow_value("#A9A").for(:color) }
|
24
|
-
it { should allow_value("#a9a9a9").for(:color) }
|
25
|
-
it { should allow_value("#A9A9A9").for(:color) }
|
26
|
-
it { should allow_value("aaa").for(:color) }
|
27
|
-
it { should allow_value("AAA").for(:color) }
|
28
|
-
it { should allow_value("aaaaaa").for(:color) }
|
29
|
-
it { should allow_value("AAAAAA").for(:color) }
|
30
|
-
it { should allow_value("999").for(:color) }
|
31
|
-
it { should allow_value("999999").for(:color) }
|
32
|
-
it { should allow_value("a9a").for(:color) }
|
33
|
-
it { should allow_value("A9A").for(:color) }
|
34
|
-
it { should allow_value("a9a9a9").for(:color) }
|
35
|
-
it { should allow_value("A9A9A9").for(:color) }
|
36
|
-
|
37
|
-
it { should_not allow_value('').for(:color) }
|
38
|
-
it { should_not allow_value(' ').for(:color) }
|
39
|
-
it { should_not allow_value(nil).for(:color) }
|
40
|
-
it { should_not allow_value("#").for(:color) }
|
41
|
-
it { should_not allow_value("#9").for(:color) }
|
42
|
-
it { should_not allow_value("#9a").for(:color) }
|
43
|
-
it { should_not allow_value("#9A").for(:color) }
|
44
|
-
it { should_not allow_value("#hhh").for(:color) }
|
45
|
-
it { should_not allow_value("#HHH").for(:color) }
|
46
|
-
it { should_not allow_value("#9h9").for(:color) }
|
47
|
-
it { should_not allow_value("#9H9").for(:color) }
|
48
|
-
it { should_not allow_value("#9a9a").for(:color) }
|
49
|
-
it { should_not allow_value("#9A9A").for(:color) }
|
50
|
-
it { should_not allow_value("#9a9a9").for(:color) }
|
51
|
-
it { should_not allow_value("#9A9A9").for(:color) }
|
52
|
-
it { should_not allow_value("#9a9a9a9").for(:color) }
|
53
|
-
it { should_not allow_value("#9A9A9A9").for(:color) }
|
54
|
-
it { should_not allow_value(" #9a9").for(:color) }
|
55
|
-
it { should_not allow_value(" #9A9").for(:color) }
|
56
|
-
it { should_not allow_value(" #9a9 ").for(:color) }
|
57
|
-
it { should_not allow_value(" #9A9 ").for(:color) }
|
58
|
-
it { should_not allow_value("#9a9 ").for(:color) }
|
59
|
-
it { should_not allow_value("#9A9 ").for(:color) }
|
60
|
-
it { should_not allow_value(" 9a9").for(:color) }
|
61
|
-
it { should_not allow_value(" 9A9").for(:color) }
|
62
|
-
it { should_not allow_value(" 9a9 ").for(:color) }
|
63
|
-
it { should_not allow_value(" 9A9 ").for(:color) }
|
64
|
-
it { should_not allow_value("9a9 ").for(:color) }
|
65
|
-
it { should_not allow_value("9A9 ").for(:color) }
|
66
|
-
it { should_not allow_value("! \#$%\`|").for(:color) }
|
67
|
-
it { should_not allow_value("<>@[]\`|").for(:color) }
|
68
|
-
|
69
|
-
it { should ensure_valid_hex_format_of(:color) }
|
70
|
-
it { should_not ensure_valid_hex_format_of(:name) }
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ImeiValidator do
|
4
|
-
|
5
|
-
context "has valid format" do
|
6
|
-
let(:klass) do
|
7
|
-
Class.new do
|
8
|
-
include ActiveModel::Validations
|
9
|
-
attr_accessor :imei, :name
|
10
|
-
validates :imei, imei: true
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
subject { klass.new }
|
15
|
-
|
16
|
-
it { should allow_value(356843052637512).for(:imei) }
|
17
|
-
it { should allow_value("356843052637512").for(:imei) }
|
18
|
-
it { should allow_value("35-684305-2637512").for(:imei) }
|
19
|
-
it { should allow_value("35-684305.263.7512").for(:imei) }
|
20
|
-
|
21
|
-
context "value too short" do
|
22
|
-
it { should_not allow_value("3568430537512").for(:imei) }
|
23
|
-
it { should_not allow_value("3").for(:imei) }
|
24
|
-
end
|
25
|
-
|
26
|
-
it "can't be too long" do
|
27
|
-
should_not allow_value("35684305263751233").for(:imei)
|
28
|
-
end
|
29
|
-
|
30
|
-
context "checksum doesn't match" do
|
31
|
-
it { should_not allow_value("356843052637513").for(:imei) }
|
32
|
-
it { should_not allow_value("156843052637512").for(:imei) }
|
33
|
-
end
|
34
|
-
|
35
|
-
it { should_not allow_value("invalid").for(:imei) }
|
36
|
-
|
37
|
-
it { should ensure_valid_imei_format_of(:imei) }
|
38
|
-
it { should_not ensure_valid_imei_format_of(:name) }
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe IpValidator do
|
4
|
-
|
5
|
-
context "has a valid value" do
|
6
|
-
let(:klass) do
|
7
|
-
Class.new do
|
8
|
-
include ActiveModel::Validations
|
9
|
-
attr_accessor :ip, :name
|
10
|
-
validates :ip, ip: true
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
subject { klass.new }
|
15
|
-
|
16
|
-
it { should allow_value("0.0.0.0").for(:ip) }
|
17
|
-
it { should allow_value("127.0.0.1").for(:ip) }
|
18
|
-
it { should allow_value("99.39.240.31").for(:ip) }
|
19
|
-
|
20
|
-
it { should_not allow_value('').for(:ip) }
|
21
|
-
it { should_not allow_value(' ').for(:ip) }
|
22
|
-
it { should_not allow_value(nil).for(:ip) }
|
23
|
-
it { should_not allow_value("0 0 0 0").for(:ip) }
|
24
|
-
it { should_not allow_value("0.0.0.0:3000").for(:ip) }
|
25
|
-
it { should_not allow_value("22.22.333.22").for(:ip) }
|
26
|
-
it { should_not allow_value("! \#$%\`|").for(:ip) }
|
27
|
-
it { should_not allow_value("<>@[]\`|").for(:ip) }
|
28
|
-
|
29
|
-
it { should ensure_valid_ip_format_of(:ip) }
|
30
|
-
it { should_not ensure_valid_ip_format_of(:name) }
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe IsbnValidator do
|
4
|
-
|
5
|
-
context "has a valid value" do
|
6
|
-
let(:klass) do
|
7
|
-
Class.new do
|
8
|
-
include ActiveModel::Validations
|
9
|
-
attr_accessor :isbn, :name
|
10
|
-
validates :isbn, isbn: true
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
subject { klass.new }
|
15
|
-
|
16
|
-
it { should allow_value("9519854894").for(:isbn) }
|
17
|
-
it { should allow_value("951 98548 9 4").for(:isbn) }
|
18
|
-
it { should allow_value("951-98548-9-4").for(:isbn) }
|
19
|
-
it { should allow_value("951-98548 9 4").for(:isbn) }
|
20
|
-
it { should allow_value("0-9722051-1-X").for(:isbn) }
|
21
|
-
it { should allow_value("0-9722051-1-x").for(:isbn) }
|
22
|
-
it { should allow_value("9781590599938").for(:isbn) }
|
23
|
-
it { should allow_value("978 159059 9938").for(:isbn) }
|
24
|
-
it { should allow_value("978-159059-9938").for(:isbn) }
|
25
|
-
it { should allow_value("978-159059 9938").for(:isbn) }
|
26
|
-
|
27
|
-
it { should_not allow_value('').for(:isbn) }
|
28
|
-
it { should_not allow_value(' ').for(:isbn) }
|
29
|
-
it { should_not allow_value(nil).for(:isbn) }
|
30
|
-
it { should_not allow_value("951-98548-9-p").for(:isbn) }
|
31
|
-
it { should_not allow_value("abc123ab3344").for(:isbn) }
|
32
|
-
it { should_not allow_value("12345678901234").for(:isbn) }
|
33
|
-
it { should_not allow_value("9991a9010599938").for(:isbn) }
|
34
|
-
it { should_not allow_value("! \#$%\`|").for(:isbn) }
|
35
|
-
it { should_not allow_value("<>@[]\`|").for(:isbn) }
|
36
|
-
|
37
|
-
it { should ensure_valid_isbn_format_of(:isbn) }
|
38
|
-
it { should_not ensure_valid_isbn_format_of(:name) }
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
@@ -1,35 +0,0 @@
|
|
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
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe LatitudeValidator do
|
4
|
-
|
5
|
-
context "has a valid value" do
|
6
|
-
let(:klass) do
|
7
|
-
Class.new do
|
8
|
-
include ActiveModel::Validations
|
9
|
-
attr_accessor :lat, :name
|
10
|
-
validates :lat, latitude: true
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
subject { klass.new }
|
15
|
-
|
16
|
-
it { should allow_value(-90).for(:lat) }
|
17
|
-
it { should allow_value(90).for(:lat) }
|
18
|
-
it { should allow_value(0).for(:lat) }
|
19
|
-
it { should allow_value(9.33).for(:lat) }
|
20
|
-
|
21
|
-
it { should_not allow_value('').for(:lat) }
|
22
|
-
it { should_not allow_value(' ').for(:lat) }
|
23
|
-
it { should_not allow_value(nil).for(:lat) }
|
24
|
-
it { should_not allow_value(-90.1).for(:lat) }
|
25
|
-
it { should_not allow_value(90.1).for(:lat) }
|
26
|
-
|
27
|
-
it { should ensure_valid_latitude_format_of(:lat) }
|
28
|
-
it { should_not ensure_valid_latitude_format_of(:name) }
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe LongitudeValidator do
|
4
|
-
|
5
|
-
context "has a valid value" do
|
6
|
-
let(:klass) do
|
7
|
-
Class.new do
|
8
|
-
include ActiveModel::Validations
|
9
|
-
attr_accessor :lon, :name
|
10
|
-
validates :lon, longitude: true
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
subject { klass.new }
|
15
|
-
|
16
|
-
it { should allow_value(-180).for(:lon) }
|
17
|
-
it { should allow_value(180).for(:lon) }
|
18
|
-
it { should allow_value(0).for(:lon) }
|
19
|
-
it { should allow_value(9.33).for(:lon) }
|
20
|
-
|
21
|
-
it { should_not allow_value('').for(:lon) }
|
22
|
-
it { should_not allow_value(' ').for(:lon) }
|
23
|
-
it { should_not allow_value(nil).for(:lon) }
|
24
|
-
it { should_not allow_value(-181.1).for(:lon) }
|
25
|
-
it { should_not allow_value(181.1).for(:lon) }
|
26
|
-
|
27
|
-
it { should ensure_valid_longitude_format_of(:lon) }
|
28
|
-
it { should_not ensure_valid_longitude_format_of(:name) }
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe MacAddressValidator do
|
4
|
-
|
5
|
-
context "has valid format" do
|
6
|
-
let(:klass) do
|
7
|
-
Class.new do
|
8
|
-
include ActiveModel::Validations
|
9
|
-
attr_accessor :mac, :name
|
10
|
-
validates :mac, mac_address: true
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
subject { klass.new }
|
15
|
-
|
16
|
-
# Valid formats
|
17
|
-
it { should allow_value("08:00:2b:01:02:03").for(:mac) }
|
18
|
-
it { should allow_value("08-00-2b-01-02-03").for(:mac) }
|
19
|
-
it { should allow_value("08.00.2b.01.02.03").for(:mac) }
|
20
|
-
it { should allow_value("08 00 2b 01 02 03").for(:mac) }
|
21
|
-
it { should allow_value("08002b:010203").for(:mac) }
|
22
|
-
it { should allow_value("08002b.010203").for(:mac) }
|
23
|
-
it { should allow_value("08002b-010203").for(:mac) }
|
24
|
-
it { should allow_value("0800.2b01.0203").for(:mac) }
|
25
|
-
it { should allow_value("0800-2b01-0203").for(:mac) }
|
26
|
-
it { should allow_value("0800 2b01 0203").for(:mac) }
|
27
|
-
it { should allow_value("08002b010203").for(:mac) }
|
28
|
-
|
29
|
-
# Mixed Separators
|
30
|
-
it { should_not allow_value("08-00:2b:01:02:03").for(:mac) }
|
31
|
-
it { should_not allow_value("08.00:2b:01:02:03").for(:mac) }
|
32
|
-
it { should_not allow_value("08 00:2b:01:02:03").for(:mac) }
|
33
|
-
it { should_not allow_value("0800-2b01:0203").for(:mac) }
|
34
|
-
it { should_not allow_value("0800 2b01:0203").for(:mac) }
|
35
|
-
|
36
|
-
# Too Short
|
37
|
-
it { should_not allow_value("08:00:2b:01:02").for(:mac) }
|
38
|
-
it { should_not allow_value("08-00-2b-01-02").for(:mac) }
|
39
|
-
|
40
|
-
# Too Long
|
41
|
-
it { should_not allow_value("08:00:2b:01:02:03:04").for(:mac) }
|
42
|
-
|
43
|
-
# Non-Hex Characters
|
44
|
-
it { should_not allow_value("qq:00:00:00:00:00").for(:mac) }
|
45
|
-
|
46
|
-
it { should_not allow_value(' ').for(:mac) }
|
47
|
-
it { should_not allow_value(nil).for(:mac) }
|
48
|
-
it { should_not allow_value("invalid").for(:mac) }
|
49
|
-
|
50
|
-
it { should ensure_valid_mac_address_format_of(:mac) }
|
51
|
-
it { should_not ensure_valid_mac_address_format_of(:name) }
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe NameValidator do
|
4
|
-
|
5
|
-
context "has a valid value" do
|
6
|
-
let(:klass) do
|
7
|
-
Class.new do
|
8
|
-
include ActiveModel::Validations
|
9
|
-
attr_accessor :name, :email
|
10
|
-
validates :name, name: true
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
subject { klass.new }
|
15
|
-
|
16
|
-
it { should allow_value("First Last").for(:name) }
|
17
|
-
it { should allow_value("First Last-Name").for(:name) }
|
18
|
-
it { should allow_value("First Middle Last").for(:name) }
|
19
|
-
it { should allow_value("Sur First Middle Last").for(:name) }
|
20
|
-
it { should allow_value("Sur First Middle Last Family").for(:name) }
|
21
|
-
it { should allow_value("Sur First Middle Last-Family").for(:name) }
|
22
|
-
|
23
|
-
it { should_not allow_value('').for(:name) }
|
24
|
-
it { should_not allow_value(' ').for(:name) }
|
25
|
-
it { should_not allow_value(nil).for(:name) }
|
26
|
-
it { should_not allow_value("First").for(:name) }
|
27
|
-
it { should_not allow_value("First Last_Name").for(:name) }
|
28
|
-
it { should_not allow_value("First1 Last").for(:name) }
|
29
|
-
it { should_not allow_value("First 1 Last").for(:name) }
|
30
|
-
it { should_not allow_value("Sur. First Middle Last Jr.").for(:name) }
|
31
|
-
it { should_not allow_value("Sur First Middle Last Family III").for(:name) }
|
32
|
-
it { should_not allow_value("! \#$%\`|").for(:name) }
|
33
|
-
it { should_not allow_value("<>@[]\`|").for(:name) }
|
34
|
-
|
35
|
-
it { should ensure_valid_name_format_of(:name) }
|
36
|
-
it { should_not ensure_valid_name_format_of(:email) }
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PasswordValidator do
|
4
|
-
|
5
|
-
context "has a valid value" do
|
6
|
-
let(:klass) do
|
7
|
-
Class.new do
|
8
|
-
include ActiveModel::Validations
|
9
|
-
attr_accessor :password, :name
|
10
|
-
validates :password, password: true
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
subject { klass.new }
|
15
|
-
|
16
|
-
it { should allow_value("password").for(:password) }
|
17
|
-
it { should allow_value("password1234").for(:password) }
|
18
|
-
it { should allow_value("pa$$word").for(:password) }
|
19
|
-
it { should allow_value("pass-word").for(:password) }
|
20
|
-
it { should allow_value("pass_word").for(:password) }
|
21
|
-
it { should allow_value("password!").for(:password) }
|
22
|
-
it { should allow_value("password@").for(:password) }
|
23
|
-
it { should allow_value("password#").for(:password) }
|
24
|
-
it { should allow_value("password%").for(:password) }
|
25
|
-
it { should allow_value("password^").for(:password) }
|
26
|
-
it { should allow_value("password&").for(:password) }
|
27
|
-
it { should allow_value("password*").for(:password) }
|
28
|
-
|
29
|
-
it { should_not allow_value('').for(:password) }
|
30
|
-
it { should_not allow_value(' ').for(:password) }
|
31
|
-
it { should_not allow_value(nil).for(:password) }
|
32
|
-
it { should_not allow_value(" password").for(:password) }
|
33
|
-
it { should_not allow_value(" password ").for(:password) }
|
34
|
-
it { should_not allow_value("password ").for(:password) }
|
35
|
-
it { should_not allow_value("pass word").for(:password) }
|
36
|
-
it { should_not allow_value("! \#$%\`|").for(:password) }
|
37
|
-
it { should_not allow_value("<>@[]\`|").for(:password) }
|
38
|
-
|
39
|
-
it { should ensure_valid_password_format_of(:password) }
|
40
|
-
it { should_not ensure_valid_password_format_of(:name) }
|
41
|
-
end
|
42
|
-
|
43
|
-
context "Password with :strict option has a valid value" do
|
44
|
-
let(:klass) do
|
45
|
-
Class.new do
|
46
|
-
include ActiveModel::Validations
|
47
|
-
attr_accessor :password, :name
|
48
|
-
validates :password, password: { strict: true }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
subject { klass.new }
|
53
|
-
|
54
|
-
it { should allow_value("Password123").for(:password) }
|
55
|
-
it { should allow_value("Password-123").for(:password) }
|
56
|
-
|
57
|
-
it { should_not allow_value('').for(:password) }
|
58
|
-
it { should_not allow_value(' ').for(:password) }
|
59
|
-
it { should_not allow_value(nil).for(:password) }
|
60
|
-
it { should_not allow_value("pass").for(:password) }
|
61
|
-
it { should_not allow_value(" password").for(:password) }
|
62
|
-
it { should_not allow_value(" password ").for(:password) }
|
63
|
-
it { should_not allow_value("password ").for(:password) }
|
64
|
-
it { should_not allow_value("pass word").for(:password) }
|
65
|
-
it { should_not allow_value("password-12345678910").for(:password) }
|
66
|
-
it { should_not allow_value("password").for(:password) }
|
67
|
-
it { should_not allow_value("password1234").for(:password) }
|
68
|
-
it { should_not allow_value("pa$$word").for(:password) }
|
69
|
-
it { should_not allow_value("pass-word").for(:password) }
|
70
|
-
it { should_not allow_value("pass_word").for(:password) }
|
71
|
-
it { should_not allow_value("password!").for(:password) }
|
72
|
-
it { should_not allow_value("password@").for(:password) }
|
73
|
-
it { should_not allow_value("password#").for(:password) }
|
74
|
-
it { should_not allow_value("password%").for(:password) }
|
75
|
-
it { should_not allow_value("password^").for(:password) }
|
76
|
-
it { should_not allow_value("password&").for(:password) }
|
77
|
-
it { should_not allow_value("password*").for(:password) }
|
78
|
-
it { should_not allow_value("! \#$%\`|").for(:password) }
|
79
|
-
it { should_not allow_value("<>@[]\`|").for(:password) }
|
80
|
-
|
81
|
-
it { should ensure_valid_password_format_of(:password) }
|
82
|
-
it { should_not ensure_valid_password_format_of(:name) }
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|