valid8ors 0.0.1
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.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +75 -0
- data/Rakefile +1 -0
- data/config/blacklist.yml +264 -0
- data/lib/blacklist_validator.rb +37 -0
- data/lib/email_format_validator.rb +25 -0
- data/test/blacklist_validator_test.rb +53 -0
- data/test/email_format_validator_test.rb +126 -0
- data/test/test_helper.rb +23 -0
- data/valid8ors.gemspec +18 -0
- metadata +71 -0
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Official.fm
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# Valid8ors
|
2
|
+
|
3
|
+
Valid8ors brings you a nice set of custom validators for Rails 3.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your Gemfile:
|
8
|
+
|
9
|
+
gem 'valid8ors'
|
10
|
+
|
11
|
+
Then run:
|
12
|
+
|
13
|
+
bundle install
|
14
|
+
|
15
|
+
## Blacklist Validator
|
16
|
+
|
17
|
+
### Usage
|
18
|
+
|
19
|
+
Add the following to one of your models:
|
20
|
+
|
21
|
+
validates :name, blacklist: true
|
22
|
+
|
23
|
+
You can also modify the default message ("is blacklisted") if validation fails:
|
24
|
+
|
25
|
+
validates :name, blacklist: { message: "is not part of the whitelist" }
|
26
|
+
|
27
|
+
### Blacklist file
|
28
|
+
|
29
|
+
You can create a blacklist.yml file in the config directory of your Rails application if you need to overload the one used by this gem.
|
30
|
+
|
31
|
+
### I18n
|
32
|
+
|
33
|
+
If you use I18n, the default key to translate is :blacklisted. So if you add to your User model:
|
34
|
+
|
35
|
+
validates :name, blacklist: true
|
36
|
+
|
37
|
+
You can translate (or overload) the default message via for e.g. using activerecord (in english): "en.activerecord.errors.models.user.attributes.name.blacklisted"
|
38
|
+
|
39
|
+
### Tests
|
40
|
+
|
41
|
+
cd test
|
42
|
+
ruby blacklist_validator_test.rb
|
43
|
+
|
44
|
+
## Email Format Validator
|
45
|
+
|
46
|
+
### Usage
|
47
|
+
|
48
|
+
Add the following to one of your models:
|
49
|
+
|
50
|
+
validates :email, email_format: true
|
51
|
+
|
52
|
+
You can also modify the default message ("is improperly formatted") if validation fails:
|
53
|
+
|
54
|
+
validates :email, email_format: { message: "is not well formatted" }
|
55
|
+
|
56
|
+
### I18n
|
57
|
+
|
58
|
+
If you use I18n, the default key to translate is :improperly_formatted. So if you add to your User model:
|
59
|
+
|
60
|
+
validates :email, email_format: true
|
61
|
+
|
62
|
+
You can translate (or overload) the default message via for e.g. (in english): "en.activerecord.errors.models.user.attributes.email.improperly_formatted"
|
63
|
+
|
64
|
+
### Tests
|
65
|
+
|
66
|
+
cd test
|
67
|
+
ruby email_format_validator_test.rb
|
68
|
+
|
69
|
+
### Credits
|
70
|
+
|
71
|
+
Regular Expression tests based on [Comparing E-mail Address Validating Regular Expressions](http://fightingforalostcause.net/misc/2006/compare-email-regex.php)
|
72
|
+
|
73
|
+
## Compatibility
|
74
|
+
|
75
|
+
Ruby 1.8 is not supported.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,264 @@
|
|
1
|
+
---
|
2
|
+
- 4r5e
|
3
|
+
- 5h1t
|
4
|
+
- 5hit
|
5
|
+
- a55
|
6
|
+
- anal
|
7
|
+
- anus
|
8
|
+
- ar5e
|
9
|
+
- arrse
|
10
|
+
- arse
|
11
|
+
- ass
|
12
|
+
- ass-fucker
|
13
|
+
- asshole
|
14
|
+
- asswhole
|
15
|
+
- a_s_s
|
16
|
+
- b!tch
|
17
|
+
- b00bs
|
18
|
+
- b17ch
|
19
|
+
- b1tch
|
20
|
+
- ballbag
|
21
|
+
- balls
|
22
|
+
- ballsack
|
23
|
+
- bastard
|
24
|
+
- beastial
|
25
|
+
- beastiality
|
26
|
+
- bellend
|
27
|
+
- bestial
|
28
|
+
- bestiality
|
29
|
+
- bi+ch
|
30
|
+
- biatch
|
31
|
+
- bitch
|
32
|
+
- bloody
|
33
|
+
- blow job
|
34
|
+
- blowjob
|
35
|
+
- boiolas
|
36
|
+
- bollock
|
37
|
+
- bollok
|
38
|
+
- boner
|
39
|
+
- boob
|
40
|
+
- booobs
|
41
|
+
- boooobs
|
42
|
+
- booooobs
|
43
|
+
- booooooobs
|
44
|
+
- breasts
|
45
|
+
- buceta
|
46
|
+
- bugger
|
47
|
+
- bum
|
48
|
+
- bunny fucker
|
49
|
+
- butt
|
50
|
+
- c0ck
|
51
|
+
- carpet muncher
|
52
|
+
- cawk
|
53
|
+
- chink
|
54
|
+
- cipa
|
55
|
+
- cl1t
|
56
|
+
- clit
|
57
|
+
- clitoris
|
58
|
+
- clits
|
59
|
+
- cnut
|
60
|
+
- cock
|
61
|
+
- cock-sucker
|
62
|
+
- cok
|
63
|
+
- coon
|
64
|
+
- cox
|
65
|
+
- crap
|
66
|
+
- cum
|
67
|
+
- cunilingus
|
68
|
+
- cunillingus
|
69
|
+
- cunnilingus
|
70
|
+
- cunt
|
71
|
+
- cyalis
|
72
|
+
- cyberfuc
|
73
|
+
- cyberfuck
|
74
|
+
- d1ck
|
75
|
+
- damn
|
76
|
+
- dick
|
77
|
+
- dildo
|
78
|
+
- dink
|
79
|
+
- dirsa
|
80
|
+
- dlck
|
81
|
+
- dog-fucker
|
82
|
+
- doggin
|
83
|
+
- donkeyribber
|
84
|
+
- doosh
|
85
|
+
- duche
|
86
|
+
- dyke
|
87
|
+
- ejaculate
|
88
|
+
- ejaculating
|
89
|
+
- ejaculation
|
90
|
+
- ejakulate
|
91
|
+
- f u c k
|
92
|
+
- f u c k e r
|
93
|
+
- f4nny
|
94
|
+
- fag
|
95
|
+
- fanny
|
96
|
+
- fanyy
|
97
|
+
- fatass
|
98
|
+
- fcuk
|
99
|
+
- feck
|
100
|
+
- felching
|
101
|
+
- fellate
|
102
|
+
- fellatio
|
103
|
+
- fingerfuck
|
104
|
+
- fistfuck
|
105
|
+
- flange
|
106
|
+
- fook
|
107
|
+
- fuck
|
108
|
+
- fudge packer
|
109
|
+
- fudgepacker
|
110
|
+
- fuk
|
111
|
+
- fux
|
112
|
+
- fux0r
|
113
|
+
- f_u_c_k
|
114
|
+
- gangbang
|
115
|
+
- gaylord
|
116
|
+
- gaysex
|
117
|
+
- goatse
|
118
|
+
- God
|
119
|
+
- god-dam
|
120
|
+
- god-damned
|
121
|
+
- goddamn
|
122
|
+
- goddamned
|
123
|
+
- hardcoresex
|
124
|
+
- hell
|
125
|
+
- heshe
|
126
|
+
- hoar
|
127
|
+
- hoare
|
128
|
+
- hoer
|
129
|
+
- homo
|
130
|
+
- hore
|
131
|
+
- horniest
|
132
|
+
- horny
|
133
|
+
- hotsex
|
134
|
+
- jack-off
|
135
|
+
- jackoff
|
136
|
+
- jap
|
137
|
+
- jerk-off
|
138
|
+
- jism
|
139
|
+
- jiz
|
140
|
+
- kawk
|
141
|
+
- knob
|
142
|
+
- kock
|
143
|
+
- kondum
|
144
|
+
- kum
|
145
|
+
- kummer
|
146
|
+
- kunilingus
|
147
|
+
- l3i+ch
|
148
|
+
- l3itch
|
149
|
+
- labia
|
150
|
+
- lmfao
|
151
|
+
- lust
|
152
|
+
- m0f0
|
153
|
+
- m0fo
|
154
|
+
- m45terbate
|
155
|
+
- ma5terb8
|
156
|
+
- ma5terbate
|
157
|
+
- masochist
|
158
|
+
- master-bate
|
159
|
+
- masterb8
|
160
|
+
- masterbat
|
161
|
+
- mo-fo
|
162
|
+
- mof0
|
163
|
+
- mofo
|
164
|
+
- mothafuck
|
165
|
+
- motherfuck
|
166
|
+
- motherfuckka
|
167
|
+
- muff
|
168
|
+
- mutha
|
169
|
+
- muthafecker
|
170
|
+
- muthafuckker
|
171
|
+
- muther
|
172
|
+
- mutherfucker
|
173
|
+
- n1gga
|
174
|
+
- n1gger
|
175
|
+
- nazi
|
176
|
+
- nigg3r
|
177
|
+
- nigg4h
|
178
|
+
- nigga
|
179
|
+
- nigger
|
180
|
+
- nob
|
181
|
+
- numbnuts
|
182
|
+
- nutsack
|
183
|
+
- orgasim
|
184
|
+
- orgasm
|
185
|
+
- p0rn
|
186
|
+
- pawn
|
187
|
+
- pecker
|
188
|
+
- penis
|
189
|
+
- phonesex
|
190
|
+
- phuck
|
191
|
+
- phuk
|
192
|
+
- phuq
|
193
|
+
- pigfucker
|
194
|
+
- pimpis
|
195
|
+
- piss
|
196
|
+
- poop
|
197
|
+
- porn
|
198
|
+
- prick
|
199
|
+
- pron
|
200
|
+
- pube
|
201
|
+
- pusse
|
202
|
+
- pussi
|
203
|
+
- pussy
|
204
|
+
- rectum
|
205
|
+
- retard
|
206
|
+
- rimjaw
|
207
|
+
- rimming
|
208
|
+
- s hit
|
209
|
+
- s.o.b.
|
210
|
+
- sadist
|
211
|
+
- schlong
|
212
|
+
- screwing
|
213
|
+
- scroat
|
214
|
+
- scrote
|
215
|
+
- scrotum
|
216
|
+
- semen
|
217
|
+
- sex
|
218
|
+
- sh!+
|
219
|
+
- sh!t
|
220
|
+
- sh1t
|
221
|
+
- shag
|
222
|
+
- shagger
|
223
|
+
- shaggin
|
224
|
+
- shagging
|
225
|
+
- shemale
|
226
|
+
- shi+
|
227
|
+
- shit
|
228
|
+
- skank
|
229
|
+
- slut
|
230
|
+
- smegma
|
231
|
+
- smut
|
232
|
+
- snatch
|
233
|
+
- son-of-a-bitch
|
234
|
+
- spac
|
235
|
+
- spunk
|
236
|
+
- s_h_i_t
|
237
|
+
- t1tt1e5
|
238
|
+
- t1tties
|
239
|
+
- teets
|
240
|
+
- teez
|
241
|
+
- testical
|
242
|
+
- testicle
|
243
|
+
- tit
|
244
|
+
- tosser
|
245
|
+
- turd
|
246
|
+
- tw4t
|
247
|
+
- twat
|
248
|
+
- twunt
|
249
|
+
- v14gra
|
250
|
+
- v1gra
|
251
|
+
- vagina
|
252
|
+
- viagra
|
253
|
+
- vulva
|
254
|
+
- w00se
|
255
|
+
- wang
|
256
|
+
- wank
|
257
|
+
- wanker
|
258
|
+
- wanky
|
259
|
+
- whoar
|
260
|
+
- whore
|
261
|
+
- willies
|
262
|
+
- willy
|
263
|
+
- xrated
|
264
|
+
- xxx
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
class BlacklistValidator < ActiveModel::EachValidator
|
4
|
+
|
5
|
+
def validate_each(record, attribute, value)
|
6
|
+
record.errors.add(attribute, options[:message] || invalid_message(record, attribute)) if blacklisted?(value)
|
7
|
+
end
|
8
|
+
|
9
|
+
# Lazy load and transform directly words to patterns instead of creating regexps at each matching tests
|
10
|
+
def blacklist
|
11
|
+
@blacklist ||= YAML.load_file(blacklist_file).map { |word| /(#{word})+/i }
|
12
|
+
end
|
13
|
+
|
14
|
+
#######################
|
15
|
+
### Private methods ###
|
16
|
+
#######################
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def invalid_message(record, attribute)
|
21
|
+
I18n.t :blacklisted,
|
22
|
+
scope: "#{record.class.i18n_scope}.errors.models.#{record.class.model_name.i18n_key}.attributes.#{attribute}",
|
23
|
+
default: "is blacklisted"
|
24
|
+
end
|
25
|
+
|
26
|
+
def blacklisted?(str)
|
27
|
+
blacklist.any? { |pattern| str =~ pattern }
|
28
|
+
end
|
29
|
+
|
30
|
+
def blacklist_file
|
31
|
+
if defined?(Rails.root) && (blacklist_file_path = Rails.root.join("config", "blacklist.yml")).exist?
|
32
|
+
return blacklist_file_path
|
33
|
+
end
|
34
|
+
File.join(File.dirname(__FILE__), "../config/blacklist.yml")
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
class EmailFormatValidator < ActiveModel::EachValidator
|
4
|
+
|
5
|
+
EMAIL_PATTERN = /\A[\w\-_\.]+@((?:[\w\-\.]+\.)+[a-z]{2,})\Z/i
|
6
|
+
|
7
|
+
def validate_each(record, attribute, value)
|
8
|
+
unless value =~ EMAIL_PATTERN
|
9
|
+
record.errors.add(attribute, options[:message] || invalid_message(record, attribute))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
#######################
|
14
|
+
### Private methods ###
|
15
|
+
#######################
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def invalid_message(record, attribute)
|
20
|
+
I18n.t :improperly_formatted,
|
21
|
+
scope: "#{record.class.i18n_scope}.errors.models.#{record.class.model_name.i18n_key}.attributes.#{attribute}",
|
22
|
+
default: "is improperly formatted"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require_relative 'test_helper'
|
4
|
+
|
5
|
+
class TestUser < TestModel
|
6
|
+
validates :name, blacklist: true
|
7
|
+
end
|
8
|
+
|
9
|
+
class TestUserWithMessage < TestModel
|
10
|
+
validates :name, blacklist: { message: 'is not part of the whitelist' }
|
11
|
+
end
|
12
|
+
|
13
|
+
class TestBlacklistValidator < MiniTest::Unit::TestCase
|
14
|
+
|
15
|
+
def test_some_blacklisted_words
|
16
|
+
names_that_should_be_blacklisted.each do |name|
|
17
|
+
test_user = TestUser.new(name: name)
|
18
|
+
refute test_user.valid?
|
19
|
+
assert test_user.errors[:name]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_some_whitelisted_words
|
24
|
+
names_that_should_be_whitelisted.each { |name| assert TestUser.new(name: name).valid? }
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_default_message_on_error
|
28
|
+
test_user = TestUser.new(name: "Get up, fuck up")
|
29
|
+
refute test_user.valid?
|
30
|
+
assert test_user.errors[:name].include?("is blacklisted")
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_custom_message_on_error
|
34
|
+
test_user = TestUserWithMessage.new(name: "Fuck it up")
|
35
|
+
refute test_user.valid?
|
36
|
+
assert test_user.errors[:name].include?("is not part of the whitelist")
|
37
|
+
end
|
38
|
+
|
39
|
+
#######################
|
40
|
+
### Private methods ###
|
41
|
+
#######################
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def names_that_should_be_blacklisted
|
46
|
+
["Fucking gay", "I have a boner", "Show me your ass"]
|
47
|
+
end
|
48
|
+
|
49
|
+
def names_that_should_be_whitelisted
|
50
|
+
["Alice in wonderland", "The Doors", "This is a simple name"]
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require_relative 'test_helper'
|
4
|
+
|
5
|
+
class TestUser < TestModel
|
6
|
+
validates :email, email_format: true
|
7
|
+
end
|
8
|
+
|
9
|
+
class TestUserAllowsNilToTrue < TestModel
|
10
|
+
validates :email, email_format: { allow_nil: true }
|
11
|
+
end
|
12
|
+
|
13
|
+
class TestUserAllowsNilToFalse < TestModel
|
14
|
+
validates :email, email_format: { allow_nil: false }
|
15
|
+
end
|
16
|
+
|
17
|
+
class TestUserWithMessage < TestModel
|
18
|
+
validates :email, email_format: { message: 'is not well formatted' }
|
19
|
+
end
|
20
|
+
|
21
|
+
class TestEmailFormatValidator < MiniTest::Unit::TestCase
|
22
|
+
|
23
|
+
def test_valid_emails
|
24
|
+
valid_emails.each { |email| assert TestUser.new(email: email).valid? }
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_invalid_emails
|
28
|
+
invalid_emails.each { |email| refute TestUser.new(email: email).valid? }
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_default_message_on_error
|
32
|
+
test_user = TestUser.new(email: "invalid_email@")
|
33
|
+
refute test_user.valid?
|
34
|
+
assert test_user.errors[:email].include?("is improperly formatted")
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_custom_message_on_error
|
38
|
+
test_user = TestUserWithMessage.new(email: "invalid_email@")
|
39
|
+
refute test_user.valid?
|
40
|
+
assert test_user.errors[:email].include?("is not well formatted")
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_nil_email_when_allow_nil_option_is_not_set
|
44
|
+
refute TestUser.new(email: nil).valid?
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_nil_email_when_allow_nil_option_is_set_to_true
|
48
|
+
assert TestUserAllowsNilToTrue.new(email: nil).valid?
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_nil_email_when_allow_nil_option_is_set_to_false
|
52
|
+
refute TestUserAllowsNilToFalse.new(email: nil).valid?
|
53
|
+
end
|
54
|
+
|
55
|
+
#######################
|
56
|
+
### Private methods ###
|
57
|
+
#######################
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def valid_emails
|
62
|
+
[
|
63
|
+
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@letters-in-local.org',
|
64
|
+
'01234567890@numbers-in-local.net',
|
65
|
+
# '&\'*+-./=?^_{}~@other-valid-characters-in-local.net',
|
66
|
+
# 'mixed-1234-in-{+^}-local@sld.net',
|
67
|
+
'a@single-character-in-local.org',
|
68
|
+
# '"quoted"@sld.com',
|
69
|
+
# '"\e\s\c\a\p\e\d"@sld.com',
|
70
|
+
# '"quoted-at-sign@sld.org"@sld.com',
|
71
|
+
# '"escaped\"quote"@sld.com',
|
72
|
+
# '"back\slash"@sld.com',
|
73
|
+
'one-character-third-level@a.example.com',
|
74
|
+
'single-character-in-sld@x.org',
|
75
|
+
'local@dash-in-sld.com',
|
76
|
+
'letters-in-sld@123.com',
|
77
|
+
'one-letter-sld@x.org',
|
78
|
+
'uncommon-tld@sld.museum',
|
79
|
+
'uncommon-tld@sld.travel',
|
80
|
+
'uncommon-tld@sld.mobi',
|
81
|
+
'country-code-tld@sld.uk',
|
82
|
+
'country-code-tld@sld.rw',
|
83
|
+
'local@sld.newTLD',
|
84
|
+
# 'punycode-numbers-in-tld@sld.xn--3e0b707e',
|
85
|
+
'the-total-length@of-an-entire-address-cannot-be-longer-than-two-hundred-and-fifty-four-characters' +
|
86
|
+
'-and-this-address-is-254-characters-exactly-so-it-should-be-valid-and-im-going-to-add-some-more' +
|
87
|
+
'-words-here-to-increase-the-lenght-blah-blah-blah-blah-bla.org',
|
88
|
+
# 'bracketed-IP-instead-of-domain@[127.0.0.1]',
|
89
|
+
'local@sub.domains.com'
|
90
|
+
]
|
91
|
+
end
|
92
|
+
|
93
|
+
def invalid_emails
|
94
|
+
[
|
95
|
+
'',
|
96
|
+
'foo@bar',
|
97
|
+
'foo@bar.c',
|
98
|
+
'foo@bar.com@bar.com',
|
99
|
+
'foo@',
|
100
|
+
'@missing-local.org',
|
101
|
+
'! #$%`|@invalid-characters-in-local.org',
|
102
|
+
'(),:;`|@more-invalid-characters-in-local.org',
|
103
|
+
'<>@[]\`|@even-more-invalid-characters-in-local.org',
|
104
|
+
# '.local-starts-with-dot@sld.com',
|
105
|
+
# 'local-ends-with-dot.@sld.com',
|
106
|
+
# 'two..consecutive-dots@sld.com',
|
107
|
+
'partially."quoted"@sld.com',
|
108
|
+
# 'the-local-part-is-invalid-if-it-is-longer-than-sixty-four-characters@sld.net',
|
109
|
+
'missing-sld@.com',
|
110
|
+
# 'sld-starts-with-dashsh@-sld.com',
|
111
|
+
# 'sld-ends-with-dash@sld-.com',
|
112
|
+
'invalid-characters-in-sld@! "#$%(),/;<>_[]`|.org',
|
113
|
+
'missing-dot-before-tld@com',
|
114
|
+
'missing-tld@sld.',
|
115
|
+
# 'the-total-length@of-an-entire-address-cannot-be-longer-than-two-hundred-and-fifty-four-characters-and' +
|
116
|
+
# '-this-address-is-255-characters-exactly-so-it-should-be-invalid-and-im-going-to-add-some-more-words' +
|
117
|
+
# '-here-to-increase-the-lenght-blah-blah-blah-blah-bl.org',
|
118
|
+
'missing-at-sign.net',
|
119
|
+
'unbracketed-IP@127.0.0.1',
|
120
|
+
'invalid-ip@127.0.0.1.26',
|
121
|
+
'another-invalid-ip@127.0.0.256',
|
122
|
+
'IP-and-port@127.0.0.1:25'
|
123
|
+
]
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'active_model'
|
5
|
+
require 'minitest/autorun'
|
6
|
+
|
7
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
8
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
9
|
+
|
10
|
+
require 'blacklist_validator'
|
11
|
+
require 'email_format_validator'
|
12
|
+
|
13
|
+
class TestModel
|
14
|
+
include ActiveModel::Validations
|
15
|
+
|
16
|
+
def initialize(attributes = {})
|
17
|
+
@attributes = attributes
|
18
|
+
end
|
19
|
+
|
20
|
+
def read_attribute_for_validation(key)
|
21
|
+
@attributes[key]
|
22
|
+
end
|
23
|
+
end
|
data/valid8ors.gemspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "valid8ors"
|
6
|
+
s.version = "0.0.1"
|
7
|
+
s.authors = ["Axel Vergult"]
|
8
|
+
s.email = ["axel@official.fm"]
|
9
|
+
s.homepage = ""
|
10
|
+
s.summary = %q{Rails 3 awesome custom validators}
|
11
|
+
s.description = %q{Rails 3 awesome custom validators}
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.add_dependency("activemodel", ">= 0")
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: valid8ors
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Axel Vergult
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-17 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activemodel
|
16
|
+
requirement: &70162532387340 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70162532387340
|
25
|
+
description: Rails 3 awesome custom validators
|
26
|
+
email:
|
27
|
+
- axel@official.fm
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- LICENSE
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- config/blacklist.yml
|
38
|
+
- lib/blacklist_validator.rb
|
39
|
+
- lib/email_format_validator.rb
|
40
|
+
- test/blacklist_validator_test.rb
|
41
|
+
- test/email_format_validator_test.rb
|
42
|
+
- test/test_helper.rb
|
43
|
+
- valid8ors.gemspec
|
44
|
+
homepage: ''
|
45
|
+
licenses: []
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 1.8.10
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: Rails 3 awesome custom validators
|
68
|
+
test_files:
|
69
|
+
- test/blacklist_validator_test.rb
|
70
|
+
- test/email_format_validator_test.rb
|
71
|
+
- test/test_helper.rb
|