This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
CHANGELOG | ||
| |
MIT-LICENSE | Tue Jan 13 19:28:34 -0800 2009 | |
| |
README.markdown | ||
| |
Rakefile | Tue Jan 13 19:28:34 -0800 2009 | |
| |
init.rb | Tue Jan 13 19:28:34 -0800 2009 | |
| |
lib/ | ||
| |
test/ | ||
| |
validates_as_hostname_label.gemspec |
README.markdown
validates_as_hostname_label
Checks for valid hostname labels by looking for:
- Length between 1 and 63 characters long
- Letters 'a' through 'z' (case-insensitive), the digits '0' through '9', and the hyphen (and optionally the underscore)
- Labels that don't begin or end with a hyphen or underscore
- Reserved labels
See http://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names
Installation
gem install shuber-validates_as_hostname_label --source http://gems.github.com
OR
script/plugin install git://github.com/shuber/validates_as_hostname_label.git
Usage
class Account < ActiveRecord::Base
validates_as_hostname_label :subdomain
end
You may optionally pass a :reserved option which should be an array of hostname labels to exclude,
otherwise Huberry::ValidatesAsHostnameLabel::RESERVED_HOSTNAMES will be used.
class Account < ActiveRecord::Base
validates_as_hostname_label :subdomain, :reserved => ['www', 'ftp', 'mail', 'pop']
end
@account = Account.new :subdomain => 'www'
@account.save # false
@account.errors # { :subdomain => 'is reserved' }
Also accepts an :allow_underscores option which defaults to false
class Account < ActiveRecord::Base
validates_as_hostname_label :subdomain, :allow_underscores => true
end
@account = Account.new :subdomain => 'test_ing'
@account.save # true
The usual validation options (like :if, :unless, :allow_nil, etc) work as well
Contact
Problems, comments, and suggestions all welcome: shuber@huberry.com








