can_has_validations 0.6.2 → 0.6.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
  SHA256:
3
- metadata.gz: 8be9db4769da71714aaf241907b6f4a25c08ba8e107e9c707aa28f9085fa8404
4
- data.tar.gz: 7839b571a0e5a397b6fd645bba0b28b3af5b0ea7c5fdbccca0d21e9dc1c7a9ac
3
+ metadata.gz: d565ec38823188e137ba900db6247e643f3c436a6a8f0be7d210a8af0f2606e6
4
+ data.tar.gz: 47fc9fc83d7224d9831d66a98e967b161b6f3fa66de7186b8b51c85ffc8287d1
5
5
  SHA512:
6
- metadata.gz: c06cad10d8a65d2c943ff3dd55c7e8d3d7a8c5a6461f0a7c153875b14c60733d539c01b4424b5fa7b204066d1956bf56e270ae24595dba5b10e0daed139a548f
7
- data.tar.gz: b9d5dd930c534575fe75a70589b18111f7c47d22978ceb53e1eab2f600908c8ebc2623e1b7a359f12a8873ca7ef6c014921279c9230122e4837b3160a85073c6
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
@@ -1,3 +1,3 @@
1
1
  module CanHasValidations
2
- VERSION = '0.6.2'
2
+ VERSION = '0.6.3'
3
3
  end
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.2
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-01 00:00:00.000000000 Z
11
+ date: 2018-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails