subdomain_validation 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +93 -1
- data/lib/subdomain_validation/version.rb +1 -1
- metadata +34 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 259fcfe3f55dc8d3ef44dceb6a443b89ea407135
|
4
|
+
data.tar.gz: 5abcd0674b67b63d360cef0318d3514218af9e49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3947da0d586329f47ad7e888fb9994d211a71f8e83a924d9d46d5825afb8f9c4d3d5c928167cf8f796e459fdeb92df5ee5073b571a6cc7e371297e5cbb2e21f2
|
7
|
+
data.tar.gz: eb77ae90188a63ddc2326600e6a6db9d2d2bc70391c3b9f3a6d40d15b5afb95ab0ef080277ef30a131edb85d3f18e4462de49913a85c37941a24b837580b6eac
|
data/README.md
CHANGED
@@ -2,6 +2,98 @@
|
|
2
2
|
|
3
3
|
Subdomain validator for Rails
|
4
4
|
|
5
|
-
|
5
|
+
## Getting Started
|
6
|
+
|
7
|
+
Add subdomain_validation gem to your Gemfile.
|
8
|
+
|
9
|
+
`gem 'subdomain_validation'`
|
10
|
+
|
11
|
+
Run bundler.
|
12
|
+
|
13
|
+
`bundle install`
|
14
|
+
|
15
|
+
## How to use
|
16
|
+
|
17
|
+
Add `SubdomainValidation` module to a model.
|
18
|
+
|
19
|
+
```rb
|
20
|
+
class User < ActiveRecord::Base
|
21
|
+
include SubdomainValidation
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
Add `validates` method on a column in the model.
|
26
|
+
|
27
|
+
```rb
|
28
|
+
class User < ActiveRecord::Base
|
29
|
+
include SubdomainValidation
|
30
|
+
|
31
|
+
validates :username, subdomain: true
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
## Validator Specifications
|
36
|
+
|
37
|
+
- Be not nil.
|
38
|
+
- Allow by using allow_nil option
|
39
|
+
- Be not blank.
|
40
|
+
- Allow by using allow_blank option
|
41
|
+
- Be not reserved name.
|
42
|
+
- Customize by using reserved_name option
|
43
|
+
- Be more than 3 characters.
|
44
|
+
- Be less than or equal to 63 characters.
|
45
|
+
- Be in alphanumeric and hyphen.
|
46
|
+
- Do not start hyphen.
|
47
|
+
- Do not end hyphen.
|
48
|
+
|
49
|
+
### Reference
|
50
|
+
|
51
|
+
[RFC 1035 - Domain names - implementation and specification](https://tools.ietf.org/html/rfc1035)
|
52
|
+
|
53
|
+
### Default Settings
|
54
|
+
|
55
|
+
- reserved_name
|
56
|
+
- The following name are prohibited to register by default. You can customize thease name.
|
57
|
+
- www
|
58
|
+
- http
|
59
|
+
- https
|
60
|
+
- ftp
|
61
|
+
- sftp
|
62
|
+
- ssl
|
63
|
+
- ns
|
64
|
+
- mx
|
65
|
+
- pop
|
66
|
+
- smtp
|
67
|
+
- admin
|
68
|
+
- mail
|
69
|
+
- users
|
70
|
+
|
71
|
+
|
72
|
+
### Options
|
73
|
+
|
74
|
+
- reserved_name
|
75
|
+
- String Array
|
76
|
+
- You can reserve the words which can not be taken.
|
77
|
+
- If use this option, then default reserved_name will be disabled.
|
78
|
+
- `validates :username, subdomain: { reserved_name: %w(www blog admin) }`
|
79
|
+
|
80
|
+
### I18n
|
81
|
+
|
82
|
+
You can customize or add validation error messages.
|
83
|
+
Add following keys to your locale file in config/locales.
|
84
|
+
|
85
|
+
```yaml
|
86
|
+
en:
|
87
|
+
subdomain_validation:
|
88
|
+
errors:
|
89
|
+
messages:
|
90
|
+
label: "can only include letters and numbers and \"-\""
|
91
|
+
first_character: "can't start with \"-\""
|
92
|
+
last_character: "can't end with \"-\""
|
93
|
+
```
|
94
|
+
|
95
|
+
Or, make a pull request :)
|
96
|
+
|
97
|
+
# License
|
6
98
|
|
7
99
|
This project rocks and uses MIT-LICENSE.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subdomain_validation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rui Onodera
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -36,56 +36,80 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
39
|
+
version: '1.3'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.3.11
|
40
43
|
type: :development
|
41
44
|
prerelease: false
|
42
45
|
version_requirements: !ruby/object:Gem::Requirement
|
43
46
|
requirements:
|
44
47
|
- - "~>"
|
45
48
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
49
|
+
version: '1.3'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.3.11
|
47
53
|
- !ruby/object:Gem::Dependency
|
48
54
|
name: rspec-rails
|
49
55
|
requirement: !ruby/object:Gem::Requirement
|
50
56
|
requirements:
|
51
57
|
- - "~>"
|
52
58
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
59
|
+
version: '3.4'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 3.4.2
|
54
63
|
type: :development
|
55
64
|
prerelease: false
|
56
65
|
version_requirements: !ruby/object:Gem::Requirement
|
57
66
|
requirements:
|
58
67
|
- - "~>"
|
59
68
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
69
|
+
version: '3.4'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 3.4.2
|
61
73
|
- !ruby/object:Gem::Dependency
|
62
74
|
name: factory_girl_rails
|
63
75
|
requirement: !ruby/object:Gem::Requirement
|
64
76
|
requirements:
|
65
77
|
- - "~>"
|
66
78
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
79
|
+
version: '4.6'
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 4.6.0
|
68
83
|
type: :development
|
69
84
|
prerelease: false
|
70
85
|
version_requirements: !ruby/object:Gem::Requirement
|
71
86
|
requirements:
|
72
87
|
- - "~>"
|
73
88
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
89
|
+
version: '4.6'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 4.6.0
|
75
93
|
- !ruby/object:Gem::Dependency
|
76
94
|
name: pry-byebug
|
77
95
|
requirement: !ruby/object:Gem::Requirement
|
78
96
|
requirements:
|
79
97
|
- - "~>"
|
80
98
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
99
|
+
version: '3.3'
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 3.3.0
|
82
103
|
type: :development
|
83
104
|
prerelease: false
|
84
105
|
version_requirements: !ruby/object:Gem::Requirement
|
85
106
|
requirements:
|
86
107
|
- - "~>"
|
87
108
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
109
|
+
version: '3.3'
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 3.3.0
|
89
113
|
description: Subdomain validator for Rails application.
|
90
114
|
email:
|
91
115
|
- deraru@gmail.com
|