can_has_validations 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/can_has_validations/validators/hostname_validator.rb +3 -1
- data/lib/can_has_validations/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d565ec38823188e137ba900db6247e643f3c436a6a8f0be7d210a8af0f2606e6
|
4
|
+
data.tar.gz: 47fc9fc83d7224d9831d66a98e967b161b6f3fa66de7186b8b51c85ffc8287d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cfa321ceee3431a7b2a99027794a655a5cd2b0a570eb715ccbaf06be183956689bfb7e369b0927d31f6a80f781591fae5422803df836fe2b41a9e52babe3bbd
|
7
|
+
data.tar.gz: 34d93b15d141061ded5dc58c2cdb62f2abe646e60c4e49e6b4ee8856d76356a3e83be0c080db3f71a5499ae095955299a3cfc978ee90d86fc50c4b465e289662
|
data/README.md
CHANGED
@@ -150,6 +150,9 @@ TLD, so as to not fail as ICANN continues to add TLDs.
|
|
150
150
|
# allows 'a.example.com', but not 'example.com'
|
151
151
|
validates :domain, hostname: {segments: 3..100}
|
152
152
|
|
153
|
+
# allows 'subdomain'
|
154
|
+
validates :subdomain, hostname: {segments: 1, skip_tld: true}
|
155
|
+
|
153
156
|
# allows '1.2.3.4' or 'a.example.com'
|
154
157
|
validates :domain, hostname: {allow_ip: true}
|
155
158
|
# use 4 or 6 for ipv4 or ipv6 only
|
@@ -22,6 +22,8 @@
|
|
22
22
|
# allows 'a.example.com', but not 'example.com'
|
23
23
|
# validates :domain, hostname: {allow_ip: true} # or 4 or 6 for ipv4 or ipv6 only
|
24
24
|
# allows '1.2.3.4' or 'a.example.com'
|
25
|
+
# validates :subdomain, hostname: {skip_tld: true, segments: 1}
|
26
|
+
# allows 'subdomain1'
|
25
27
|
|
26
28
|
require 'resolv'
|
27
29
|
|
@@ -56,7 +58,7 @@ module ActiveModel::Validations
|
|
56
58
|
is_valid &&= labels.size.in? segments
|
57
59
|
labels.each_with_index do |label, idx|
|
58
60
|
is_valid &&= label.length <= 63
|
59
|
-
if idx+1==labels.size
|
61
|
+
if !options[:skip_tld] && idx+1==labels.size
|
60
62
|
is_valid &&= label =~ FINAL_LABEL_REGEXP
|
61
63
|
elsif options[:allow_wildcard] && idx==0
|
62
64
|
is_valid &&= label=='*' || label =~ LABEL_REGEXP
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: can_has_validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thomas morgan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|