File: test_model.rb

package info (click to toggle)
ruby-validates-hostname 1.0.13-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 196 kB
  • sloc: ruby: 774; makefile: 3
file content (52 lines) | stat: -rw-r--r-- 1,538 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
class Record < ActiveRecord::Base
  validates :name,
            :hostname => true

  validates :name_with_underscores,
            :hostname => { :allow_underscore => true }

  validates :name_with_wildcard,
            :hostname => { :allow_wildcard_hostname => true }

  validates :name_with_numeric_hostname,
            :hostname => { :allow_numeric_hostname => true }

  validates :name_with_blank,
            :hostname => true,
            :allow_blank => true

  validates :name_with_nil,
            :hostname => true,
            :allow_nil => true

  validates :name_with_valid_tld,
            :hostname => { :require_valid_tld => true }

  validates :name_with_test_tld,
            :hostname => { :require_valid_tld => true, :valid_tlds => %w(test) }

  validates :name_with_valid_root_label,
            :hostname => { :allow_root_label => true },
            :allow_nil => true,
            :allow_blank => true

  validates :name_with_invalid_root_label,
            :hostname => true,
            :allow_nil => true,
            :allow_blank => true

  validates :domainname_with_numeric_hostname,
            :domainname => true,
            :allow_nil => true,
            :allow_blank => true

  validates :domainname_with_valid_root_label,
            :domainname => { :allow_root_label => true },
            :allow_nil => true,
            :allow_blank => true

  validates :domainname_with_invalid_root_label,
            :domainname => true,
            :allow_nil => true,
            :allow_blank => true
end