missing_validators 0.8.2 → 0.8.3
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8965924e44993f7bfad6dcfd4a63917f544e417
|
4
|
+
data.tar.gz: 3a114c7b78f19d3384012dcefc5d7656514a5613
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a6b1635cb5c6980b98cca25389c6f1b1a903197684d20ee4adb1de3e50674c50749d3dab2619cc50d3b31e05e353e44ee3f8fe3fa2dd262617a8e69b0edfaf3
|
7
|
+
data.tar.gz: 455faa6aa3d3a22b9ed992dc6d2a6bf4e9e67aff8391eca21e3ea86da435d9d0e14777cffe1841ddada8f1112557d5cf4edb999a002340148e270ec3145799d8
|
@@ -21,12 +21,12 @@ class MacAddressValidator < ActiveModel::EachValidator
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.validate_format(mac_address)
|
24
|
-
!!(mac_address =~ /^([\h]{2}
|
25
|
-
!!(mac_address =~ /^([\h]{2}[
|
26
|
-
!!(mac_address =~ /^([\h]{6})
|
27
|
-
!!(mac_address =~ /^([\h]{6})
|
28
|
-
!!(mac_address =~ /^([\h]{4}[
|
29
|
-
!!(mac_address =~ /^[\h]{12}?$/i)
|
24
|
+
!!(mac_address =~ /^([\h]{2}:){5}[\h]{2}?$/i) || # 08:00:2b:01:02:03
|
25
|
+
!!(mac_address =~ /^([\h]{2}[-|\.|\s]){5}[\h]{2}?$/i) || # 08-00-2b-01-02-03 or 08.00.2b.01.02.03
|
26
|
+
!!(mac_address =~ /^([\h]{6})[-|\.][\h]{6}?$/i) || # 08002b-010203 or 08002b.010203
|
27
|
+
!!(mac_address =~ /^([\h]{6}):[\h]{6}?$/i) || # 08002b:010203
|
28
|
+
!!(mac_address =~ /^([\h]{4}[-|\.|\s]){2}[\h]{4}?$/i) || # 0800.2b01.0203 or 0800-2b01-0203 0800 2b01 0203
|
29
|
+
!!(mac_address =~ /^[\h]{12}?$/i) # 08002b010203
|
30
30
|
end
|
31
31
|
|
32
32
|
private
|
data/lib/missing_validators.rb
CHANGED
@@ -15,18 +15,36 @@ describe MacAddressValidator do
|
|
15
15
|
it { should ensure_valid_mac_address_format_of(:mac) }
|
16
16
|
it { should_not ensure_valid_mac_address_format_of(:name) }
|
17
17
|
|
18
|
+
# Valid formats
|
18
19
|
it { should allow_value("08:00:2b:01:02:03").for(:mac) }
|
19
20
|
it { should allow_value("08-00-2b-01-02-03").for(:mac) }
|
21
|
+
it { should allow_value("08.00.2b.01.02.03").for(:mac) }
|
22
|
+
it { should allow_value("08 00 2b 01 02 03").for(:mac) }
|
20
23
|
it { should allow_value("08002b:010203").for(:mac) }
|
24
|
+
it { should allow_value("08002b.010203").for(:mac) }
|
21
25
|
it { should allow_value("08002b-010203").for(:mac) }
|
22
26
|
it { should allow_value("0800.2b01.0203").for(:mac) }
|
27
|
+
it { should allow_value("0800-2b01-0203").for(:mac) }
|
28
|
+
it { should allow_value("0800 2b01 0203").for(:mac) }
|
23
29
|
it { should allow_value("08002b010203").for(:mac) }
|
24
30
|
|
31
|
+
# Mixed Separators
|
32
|
+
it { should_not allow_value("08-00:2b:01:02:03").for(:mac) }
|
33
|
+
it { should_not allow_value("08.00:2b:01:02:03").for(:mac) }
|
34
|
+
it { should_not allow_value("08 00:2b:01:02:03").for(:mac) }
|
35
|
+
it { should_not allow_value("0800-2b01:0203").for(:mac) }
|
36
|
+
it { should_not allow_value("0800 2b01:0203").for(:mac) }
|
37
|
+
|
38
|
+
# Too Short
|
25
39
|
it { should_not allow_value("08:00:2b:01:02").for(:mac) }
|
40
|
+
it { should_not allow_value("08-00-2b-01-02").for(:mac) }
|
41
|
+
|
42
|
+
# Too Long
|
26
43
|
it { should_not allow_value("08:00:2b:01:02:03:04").for(:mac) }
|
44
|
+
|
45
|
+
# Non-Hex Characters
|
27
46
|
it { should_not allow_value("qq:00:00:00:00:00").for(:mac) }
|
28
47
|
|
29
|
-
it { should_not allow_value("08-00-2b-01-02").for(:mac) }
|
30
48
|
|
31
49
|
it { should_not allow_value("invalid").for(:mac) }
|
32
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: missing_validators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Gridnev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|