active_validation 1.1.0 → 2.0.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/Rakefile +3 -1
- data/active_validation.gemspec +1 -0
- data/config/locales/en.yml +4 -0
- data/lib/active_validation/matchers/ensure_valid_alpha_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_alpha_numeric_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_base64_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_boolean_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_coordinate_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_credit_card_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_currency_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_cusip_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_email_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_equality_matcher_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_hex_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_imei_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_ip_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_isbn_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_isin_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_mac_address_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_name_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_password_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_phone_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_sedol_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_slug_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_ssn_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_tracking_number_format_of.rb +26 -0
- data/lib/active_validation/matchers/ensure_valid_url_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_username_format_of.rb +2 -2
- data/lib/active_validation/matchers/ensure_valid_uuid_format_of.rb +2 -2
- data/lib/active_validation/validators/alpha_numeric_validator.rb +10 -7
- data/lib/active_validation/validators/alpha_validator.rb +10 -8
- data/lib/active_validation/validators/base64_validator.rb +16 -1
- data/lib/active_validation/validators/coordinate_validator.rb +12 -3
- data/lib/active_validation/validators/credit_card_validator.rb +10 -10
- data/lib/active_validation/validators/currency_validator.rb +7 -6
- data/lib/active_validation/validators/cusip_validator.rb +11 -9
- data/lib/active_validation/validators/email_validator.rb +11 -7
- data/lib/active_validation/validators/equality_validator.rb +14 -7
- data/lib/active_validation/validators/hex_validator.rb +16 -1
- data/lib/active_validation/validators/imei_validator.rb +14 -12
- data/lib/active_validation/validators/ip_validator.rb +16 -1
- data/lib/active_validation/validators/isbn_validator.rb +8 -4
- data/lib/active_validation/validators/isin_validator.rb +16 -14
- data/lib/active_validation/validators/mac_address_validator.rb +21 -7
- data/lib/active_validation/validators/name_validator.rb +16 -1
- data/lib/active_validation/validators/password_validator.rb +7 -6
- data/lib/active_validation/validators/phone_validator.rb +16 -1
- data/lib/active_validation/validators/sedol_validator.rb +15 -10
- data/lib/active_validation/validators/slug_validator.rb +16 -1
- data/lib/active_validation/validators/ssn_validator.rb +16 -1
- data/lib/active_validation/validators/tracking_number_validator.rb +235 -0
- data/lib/active_validation/validators/url_validator.rb +11 -2
- data/lib/active_validation/validators/username_validator.rb +16 -1
- data/lib/active_validation/validators/uuid_validator.rb +11 -6
- data/lib/active_validation/version.rb +1 -1
- data/lib/active_validation.rb +5 -6
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30fc4f9a1e1513760c6a6e89377de0ec0fad9986
|
4
|
+
data.tar.gz: 5c53383b55cbe7500f0665375035599b759ae9f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 899cd1d1afea9f43a373f483d8ebb18bb12191e4f85f903332529f29ed0f57602d2754ff48b6a9f3604b0bd16aa2cb7b2aa2a1b5dbce4325851a8e64908fbff0
|
7
|
+
data.tar.gz: 5aac70ad5078bdecd33492af3c9bb1cb4a82e0496bfe757fbe10c660a72e57a9db2b7f4bea14609c872cfa99df6e06867019b687f5d03b0b30bba624a82ec82c
|
data/Rakefile
CHANGED
data/active_validation.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_runtime_dependency "activemodel"
|
23
23
|
spec.add_runtime_dependency "activesupport"
|
24
|
+
spec.add_runtime_dependency "active_object"
|
24
25
|
|
25
26
|
spec.add_development_dependency "bundler"
|
26
27
|
spec.add_development_dependency "coveralls"
|
data/config/locales/en.yml
CHANGED
@@ -27,6 +27,7 @@ en:
|
|
27
27
|
sedol: "is not a valid SEDOL"
|
28
28
|
slug: "is not a valid slug"
|
29
29
|
ssn: "is not a valid social security number"
|
30
|
+
tracking_number: "is not a valid tracking number"
|
30
31
|
url: "is not a valid URL"
|
31
32
|
username: "is not a valid username"
|
32
33
|
uuid: "is not a valid UUID"
|
@@ -97,6 +98,9 @@ en:
|
|
97
98
|
ensure_valid_ssn_format_of:
|
98
99
|
failure_message_for_should: "%{model} should ensure valid SSN format of attribute %{attr}"
|
99
100
|
failure_message_for_should_not: "%{model} should not ensure valid SSN format of attribute %{attr}"
|
101
|
+
ensure_valid_tracking_number_format_of:
|
102
|
+
failure_message_for_should: "%{model} should ensure valid tracking number format of attribute %{attr}"
|
103
|
+
failure_message_for_should_not: "%{model} should not ensure valid tracking number format of attribute %{attr}"
|
100
104
|
ensure_valid_url_format_of:
|
101
105
|
failure_message_for_should: "%{model} should ensure valid URL format of attribute %{attr}"
|
102
106
|
failure_message_for_should_not: "%{model} should not ensure valid URL format of attribute %{attr}"
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_alpha_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_alpha_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_alpha_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_alpha_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_alpha_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_alpha_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_alpha_numeric_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_alpha_numeric_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_alpha_numeric_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_alpha_numeric_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_alpha_numeric_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_alpha_numeric_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_base64_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_base64_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_base64_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_base64_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_base64_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_base64_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_boolean_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_boolean_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_boolean_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_boolean_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_boolean_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_boolean_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_coordinate_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_coordinate_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_coordinate_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_coordinate_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_coordinate_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_coordinate_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_credit_card_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_credit_card_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_credit_card_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_credit_card_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_credit_card_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_credit_card_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_currency_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_currency_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_currency_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_currency_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_currency_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_currency_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_cusip_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_cusip_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_cusip_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_cusip_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_cusip_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_cusip_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_email_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_email_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_email_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_email_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_email_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_email_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -22,7 +22,7 @@ RSpec::Matchers.define :ensure_equality_of do |attribute|
|
|
22
22
|
|
23
23
|
failure_message do |model|
|
24
24
|
I18n.t(
|
25
|
-
'active_validation.matchers.ensure_valid_equality_format_of.failure_message_for_should',
|
25
|
+
'active_validation.errors.matchers.ensure_valid_equality_format_of.failure_message_for_should',
|
26
26
|
attr: attribute.inspect,
|
27
27
|
model: model.class.name,
|
28
28
|
operator: "operator"
|
@@ -31,7 +31,7 @@ RSpec::Matchers.define :ensure_equality_of do |attribute|
|
|
31
31
|
|
32
32
|
failure_message_when_negated do |model|
|
33
33
|
I18n.t(
|
34
|
-
'active_validation.matchers.ensure_valid_equality_format_of.failure_message_for_should_not',
|
34
|
+
'active_validation.errors.matchers.ensure_valid_equality_format_of.failure_message_for_should_not',
|
35
35
|
attr: attribute.inspect,
|
36
36
|
model: model.class.name,
|
37
37
|
operator: "operator"
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_hex_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_hex_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_hex_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_hex_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_hex_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_hex_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_imei_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_imei_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_imei_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_imei_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_imei_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_imei_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_ip_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_ip_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_ip_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_ip_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_ip_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_ip_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_isbn_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_isbn_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_isbn_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_isbn_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_isbn_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_isbn_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_isin_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_isin_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_isin_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_isin_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_isin_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_isin_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_mac_address_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_mac_address_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_mac_address_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_mac_address_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_mac_address_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_mac_address_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_name_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_name_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_name_format_of.failure_message_for_should',
|
14
14
|
attribute: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_name_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_name_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_name_format_of.failure_message_for_should_not',
|
22
22
|
attribute: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_password_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_password_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_password_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_password_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_password_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_password_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_phone_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_phone_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_phone_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_phone_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_phone_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_phone_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_sedol_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_sedol_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_sedol_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_sedol_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_sedol_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_sedol_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_slug_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_slug_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_slug_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_slug_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_slug_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_slug_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_ssn_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_ssn_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_ssn_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_ssn_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_ssn_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_ssn_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RSpec::Matchers.define :ensure_valid_tracking_number_format_of do |attribute|
|
2
|
+
match do |model|
|
3
|
+
model.send("#{attribute}=", "3318810026")
|
4
|
+
model.valid?
|
5
|
+
|
6
|
+
if model.errors.has_key?(attribute)
|
7
|
+
model.errors[attribute].include?(I18n.t('active_validation.errors.messages.tracking_number'))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message do |model|
|
12
|
+
I18n.t(
|
13
|
+
'active_validation.errors.matchers.ensure_valid_tracking_number_format_of.failure_message_for_should',
|
14
|
+
attr: attribute.inspect,
|
15
|
+
model: model.class.name
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message_when_negated do |model|
|
20
|
+
I18n.t(
|
21
|
+
'active_validation.errors.matchers.ensure_valid_tracking_number_format_of.failure_message_for_should_not',
|
22
|
+
attr: attribute.inspect,
|
23
|
+
model: model.class.name
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_url_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_url_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_url_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_url_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_url_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_url_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_username_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_username_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_username_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_username_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_username_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_username_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -10,7 +10,7 @@ RSpec::Matchers.define :ensure_valid_uuid_format_of do |attribute|
|
|
10
10
|
|
11
11
|
failure_message do |model|
|
12
12
|
I18n.t(
|
13
|
-
'active_validation.matchers.ensure_valid_uuid_format_of.failure_message_for_should',
|
13
|
+
'active_validation.errors.matchers.ensure_valid_uuid_format_of.failure_message_for_should',
|
14
14
|
attr: attribute.inspect,
|
15
15
|
model: model.class.name
|
16
16
|
)
|
@@ -18,7 +18,7 @@ RSpec::Matchers.define :ensure_valid_uuid_format_of do |attribute|
|
|
18
18
|
|
19
19
|
failure_message_when_negated do |model|
|
20
20
|
I18n.t(
|
21
|
-
'active_validation.matchers.ensure_valid_uuid_format_of.failure_message_for_should_not',
|
21
|
+
'active_validation.errors.matchers.ensure_valid_uuid_format_of.failure_message_for_should_not',
|
22
22
|
attr: attribute.inspect,
|
23
23
|
model: model.class.name
|
24
24
|
)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class AlphaNumericValidator < ActiveModel::EachValidator
|
2
2
|
|
3
3
|
def validate_each(record, attribute, value)
|
4
|
-
unless valid?(value, options)
|
4
|
+
unless valid?(value.to_s, options)
|
5
5
|
record.errors[attribute] << (options[:message] || I18n.t('active_validation.errors.messages.alpha_numeric'))
|
6
6
|
end
|
7
7
|
end
|
@@ -9,22 +9,25 @@ class AlphaNumericValidator < ActiveModel::EachValidator
|
|
9
9
|
private
|
10
10
|
|
11
11
|
def valid_format?(value, options)
|
12
|
-
|
12
|
+
strict = options.fetch(:strict, false)
|
13
|
+
|
14
|
+
value =~ case options[:case]
|
13
15
|
when :lower
|
14
|
-
|
16
|
+
strict ? /^[a-z0-9]+$/ : /^[a-z0-9 ]+$/
|
15
17
|
when :upper
|
16
|
-
|
18
|
+
strict ? /^[A-Z0-9]+$/ : /^[A-Z0-9 ]+$/
|
17
19
|
else
|
18
|
-
|
20
|
+
strict ? /^[A-Za-z0-9]+$/i : /^[A-Za-z0-9 ]+$/i
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
22
24
|
def valid_length?(value)
|
23
|
-
value
|
25
|
+
value.present?
|
24
26
|
end
|
25
27
|
|
26
28
|
def valid?(value, options)
|
27
|
-
|
29
|
+
valid_length?(value) &&
|
30
|
+
valid_format?(value, options)
|
28
31
|
end
|
29
32
|
|
30
33
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class AlphaValidator < ActiveModel::EachValidator
|
2
2
|
|
3
3
|
def validate_each(record, attribute, value)
|
4
|
-
unless valid?(value, options)
|
4
|
+
unless valid?(value.to_s, options)
|
5
5
|
record.errors[attribute] << (options[:message] || I18n.t('active_validation.errors.messages.alpha'))
|
6
6
|
end
|
7
7
|
end
|
@@ -9,23 +9,25 @@ class AlphaValidator < ActiveModel::EachValidator
|
|
9
9
|
private
|
10
10
|
|
11
11
|
def valid_format?(value, options)
|
12
|
-
|
12
|
+
strict = options.fetch(:strict, false)
|
13
|
+
|
14
|
+
value =~ case options[:case]
|
13
15
|
when :lower
|
14
|
-
|
16
|
+
strict ? /^[a-z]+$/ : /^[a-z ]+$/
|
15
17
|
when :upper
|
16
|
-
|
18
|
+
strict ? /^[A-Z]+$/ : /^[A-Z ]+$/
|
17
19
|
else
|
18
|
-
|
20
|
+
strict ? /^[A-Za-z]+$/i : /^[A-Za-z ]+$/i
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
22
24
|
def valid_length?(value)
|
23
|
-
value
|
25
|
+
value.present?
|
24
26
|
end
|
25
27
|
|
26
28
|
def valid?(value, options)
|
27
|
-
|
28
|
-
|
29
|
+
valid_length?(value) &&
|
30
|
+
valid_format?(value, options)
|
29
31
|
end
|
30
32
|
|
31
33
|
end
|