validators 3.0.5 → 3.1.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 +31 -2
- data/data/reserved_hostnames.json +1399 -0
- data/lib/validators/locale/en.yml +27 -0
- data/lib/validators/locale/pt-BR.yml +27 -0
- data/lib/validators/reserved_hostnames.rb +49 -0
- data/lib/validators/validates_reserved_hostname.rb +45 -0
- data/lib/validators/validates_reserved_username.rb +29 -0
- data/lib/validators/version.rb +2 -2
- data/lib/validators.rb +6 -0
- data/test/support/models.rb +12 -0
- data/test/test_helper.rb +3 -13
- data/test/validators/disposable_email_test.rb +2 -1
- data/test/validators/validates_reserved_hostname_test.rb +40 -0
- data/test/validators/validates_reserved_username_test.rb +40 -0
- metadata +12 -4
- data/test/support/translations.yml +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d59b19552e6feb2768bdebb407805ac932ae8ab96bcb6184661f388cadd5ed74
|
4
|
+
data.tar.gz: 657cd7b8292255b0c6c995dc5acb7ac2db333f70ff1ed8c5cbdf72b86aaa21a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f3eed7777518563b684699beb31c8b41e000d7b6df922f90fad6e0e9f185695fe785bfc2d1e4699a3c7f90cf4ba9b1588f2a68a4e3b8a28e70555108d5e2bc6
|
7
|
+
data.tar.gz: 8df8d756b890bfac3d2c6d1b0191cdcf80250602a0dd93caf67acfead1e2529d164f05c5b24b535b94080634096111c19cbc05ee8a5f190e3369e33e297034a1
|
data/README.md
CHANGED
@@ -32,7 +32,8 @@ class User < ActiveRecord::Base
|
|
32
32
|
end
|
33
33
|
```
|
34
34
|
|
35
|
-
By default, it rejects disposable e-mails (e.g. mailinator). This loads ~15kb,
|
35
|
+
By default, it rejects disposable e-mails (e.g. mailinator). This loads ~15kb,
|
36
|
+
but you can disable this validation by setting `disposable: true`.
|
36
37
|
|
37
38
|
```ruby
|
38
39
|
class User < ActiveRecord::Base
|
@@ -143,9 +144,37 @@ class Server < ActiveRecord::Base
|
|
143
144
|
end
|
144
145
|
```
|
145
146
|
|
147
|
+
### validates_reserved_username / validates_reserved_hostname
|
148
|
+
|
149
|
+
The compiled list will be used for both username and hostname validations.
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
class Server < ActiveRecord::Base
|
153
|
+
validates_reserved_hostname :hostname
|
154
|
+
end
|
155
|
+
|
156
|
+
class User < ActiveRecord::Base
|
157
|
+
validates_reserved_username :username
|
158
|
+
end
|
159
|
+
```
|
160
|
+
|
161
|
+
You can also provide your own list if you want. Any string that starts with `/`
|
162
|
+
will be parsed with `Regexp.compile`.
|
163
|
+
|
164
|
+
```ruby
|
165
|
+
ReservedUsernames = Validators::ReservedHostnames.parse_list([
|
166
|
+
"www",
|
167
|
+
"/www[0-9-]+/"
|
168
|
+
])
|
169
|
+
|
170
|
+
class User < ActiveRecord::Base
|
171
|
+
validates_reserved_username, in: ReservedUsernames
|
172
|
+
end
|
173
|
+
```
|
174
|
+
|
146
175
|
## Maintainer
|
147
176
|
|
148
|
-
* [Nando Vieira](http://
|
177
|
+
* [Nando Vieira](http://nandovieira.com)
|
149
178
|
|
150
179
|
## License
|
151
180
|
|