flash_validators 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -3
- data/README.md +483 -232
- data/config/locales/en.yml +12 -0
- data/lib/flash_validators.rb +6 -0
- data/lib/flash_validators/matchers/ensure_valid_alpha_format_of.rb +18 -0
- data/lib/flash_validators/matchers/ensure_valid_alpha_numeric_format_of.rb +18 -0
- data/lib/flash_validators/matchers/ensure_valid_boolean_format_of.rb +2 -4
- data/lib/flash_validators/matchers/ensure_valid_credit_card_format_of.rb +18 -0
- data/lib/flash_validators/matchers/ensure_valid_currency_format_of.rb +2 -4
- data/lib/flash_validators/matchers/ensure_valid_email_format_of.rb +2 -4
- data/lib/flash_validators/matchers/ensure_valid_equality_matcher_of.rb +2 -4
- data/lib/flash_validators/matchers/ensure_valid_hex_format_of.rb +2 -4
- data/lib/flash_validators/matchers/ensure_valid_imei_format_of.rb +2 -4
- data/lib/flash_validators/matchers/ensure_valid_ip_format_of.rb +2 -4
- data/lib/flash_validators/matchers/ensure_valid_latitude_format_of.rb +2 -4
- data/lib/flash_validators/matchers/ensure_valid_longitude_format_of.rb +2 -4
- data/lib/flash_validators/matchers/ensure_valid_mac_address_format_of.rb +2 -4
- data/lib/flash_validators/matchers/ensure_valid_name_format_of.rb +2 -4
- data/lib/flash_validators/matchers/ensure_valid_password_format_of.rb +2 -4
- data/lib/flash_validators/matchers/ensure_valid_phone_format_of.rb +2 -4
- data/lib/flash_validators/matchers/ensure_valid_slug_format_of.rb +2 -4
- data/lib/flash_validators/matchers/ensure_valid_ssn_format_of.rb +2 -4
- data/lib/flash_validators/matchers/ensure_valid_url_format_of.rb +2 -4
- data/lib/flash_validators/matchers/ensure_valid_username_format_of.rb +2 -4
- data/lib/flash_validators/validators/alpha_numeric_validator.rb +17 -0
- data/lib/flash_validators/validators/alpha_validator.rb +19 -0
- data/lib/flash_validators/validators/credit_card_validator.rb +25 -0
- data/lib/flash_validators/validators/password_validator.rb +9 -1
- data/lib/flash_validators/version.rb +2 -2
- data/spec/lib/alpha_numeric_validator_spec.rb +61 -0
- data/spec/lib/alpha_validator_spec.rb +120 -0
- data/spec/lib/credit_card_validator_spec.rb +316 -0
- data/spec/lib/currency_validator_spec.rb +1 -1
- data/spec/lib/password_validator_spec.rb +42 -0
- metadata +15 -3
@@ -31,7 +31,7 @@ describe CurrencyValidator do
|
|
31
31
|
it { should_not ensure_valid_currency_format_of(:name) }
|
32
32
|
end
|
33
33
|
|
34
|
-
context "Currency with strict option has a valid value" do
|
34
|
+
context "Currency with :strict option has a valid value" do
|
35
35
|
let(:klass) do
|
36
36
|
Class.new do
|
37
37
|
include ActiveModel::Validations
|
@@ -42,4 +42,46 @@ describe PasswordValidator do
|
|
42
42
|
it { should_not ensure_valid_password_format_of(:name) }
|
43
43
|
end
|
44
44
|
|
45
|
+
context "Password with :strict option has a valid value" do
|
46
|
+
let(:klass) do
|
47
|
+
Class.new do
|
48
|
+
include ActiveModel::Validations
|
49
|
+
attr_accessor :password, :name
|
50
|
+
validates :password, password: { strict: true }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
subject { klass.new }
|
55
|
+
|
56
|
+
it { should allow_value("Password123").for(:password) }
|
57
|
+
it { should allow_value("Password-123").for(:password) }
|
58
|
+
|
59
|
+
it { should_not allow_value('').for(:password) }
|
60
|
+
it { should_not allow_value(' ').for(:password) }
|
61
|
+
it { should_not allow_value(nil).for(:password) }
|
62
|
+
it { should_not allow_value("pass").for(:password) }
|
63
|
+
it { should_not allow_value(" password").for(:password) }
|
64
|
+
it { should_not allow_value(" password ").for(:password) }
|
65
|
+
it { should_not allow_value("password ").for(:password) }
|
66
|
+
it { should_not allow_value("pass word").for(:password) }
|
67
|
+
it { should_not allow_value("password-12345678910").for(:password) }
|
68
|
+
it { should_not allow_value("password").for(:password) }
|
69
|
+
it { should_not allow_value("password1234").for(:password) }
|
70
|
+
it { should_not allow_value("pa$$word").for(:password) }
|
71
|
+
it { should_not allow_value("pass-word").for(:password) }
|
72
|
+
it { should_not allow_value("pass_word").for(:password) }
|
73
|
+
it { should_not allow_value("password!").for(:password) }
|
74
|
+
it { should_not allow_value("password@").for(:password) }
|
75
|
+
it { should_not allow_value("password#").for(:password) }
|
76
|
+
it { should_not allow_value("password%").for(:password) }
|
77
|
+
it { should_not allow_value("password^").for(:password) }
|
78
|
+
it { should_not allow_value("password&").for(:password) }
|
79
|
+
it { should_not allow_value("password*").for(:password) }
|
80
|
+
it { should_not allow_value("! \#$%\`|").for(:password) }
|
81
|
+
it { should_not allow_value("<>@[]\`|").for(:password) }
|
82
|
+
|
83
|
+
it { should ensure_valid_password_format_of(:password) }
|
84
|
+
it { should_not ensure_valid_password_format_of(:name) }
|
85
|
+
end
|
86
|
+
|
45
87
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flash_validators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -126,7 +126,10 @@ files:
|
|
126
126
|
- config/locales/en.yml
|
127
127
|
- flash_validators.gemspec
|
128
128
|
- lib/flash_validators.rb
|
129
|
+
- lib/flash_validators/matchers/ensure_valid_alpha_format_of.rb
|
130
|
+
- lib/flash_validators/matchers/ensure_valid_alpha_numeric_format_of.rb
|
129
131
|
- lib/flash_validators/matchers/ensure_valid_boolean_format_of.rb
|
132
|
+
- lib/flash_validators/matchers/ensure_valid_credit_card_format_of.rb
|
130
133
|
- lib/flash_validators/matchers/ensure_valid_currency_format_of.rb
|
131
134
|
- lib/flash_validators/matchers/ensure_valid_email_format_of.rb
|
132
135
|
- lib/flash_validators/matchers/ensure_valid_equality_matcher_of.rb
|
@@ -143,7 +146,10 @@ files:
|
|
143
146
|
- lib/flash_validators/matchers/ensure_valid_ssn_format_of.rb
|
144
147
|
- lib/flash_validators/matchers/ensure_valid_url_format_of.rb
|
145
148
|
- lib/flash_validators/matchers/ensure_valid_username_format_of.rb
|
149
|
+
- lib/flash_validators/validators/alpha_numeric_validator.rb
|
150
|
+
- lib/flash_validators/validators/alpha_validator.rb
|
146
151
|
- lib/flash_validators/validators/boolean_validator.rb
|
152
|
+
- lib/flash_validators/validators/credit_card_validator.rb
|
147
153
|
- lib/flash_validators/validators/currency_validator.rb
|
148
154
|
- lib/flash_validators/validators/email_validator.rb
|
149
155
|
- lib/flash_validators/validators/equality_validator.rb
|
@@ -161,7 +167,10 @@ files:
|
|
161
167
|
- lib/flash_validators/validators/url_validator.rb
|
162
168
|
- lib/flash_validators/validators/username_validator.rb
|
163
169
|
- lib/flash_validators/version.rb
|
170
|
+
- spec/lib/alpha_numeric_validator_spec.rb
|
171
|
+
- spec/lib/alpha_validator_spec.rb
|
164
172
|
- spec/lib/boolean_validator_spec.rb
|
173
|
+
- spec/lib/credit_card_validator_spec.rb
|
165
174
|
- spec/lib/currency_validator_spec.rb
|
166
175
|
- spec/lib/email_validator_spec.rb
|
167
176
|
- spec/lib/equality_validator_spec.rb
|
@@ -199,12 +208,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
208
|
version: '0'
|
200
209
|
requirements: []
|
201
210
|
rubyforge_project:
|
202
|
-
rubygems_version: 2.
|
211
|
+
rubygems_version: 2.3.0
|
203
212
|
signing_key:
|
204
213
|
specification_version: 4
|
205
214
|
summary: Gem for commonly used model validators.
|
206
215
|
test_files:
|
216
|
+
- spec/lib/alpha_numeric_validator_spec.rb
|
217
|
+
- spec/lib/alpha_validator_spec.rb
|
207
218
|
- spec/lib/boolean_validator_spec.rb
|
219
|
+
- spec/lib/credit_card_validator_spec.rb
|
208
220
|
- spec/lib/currency_validator_spec.rb
|
209
221
|
- spec/lib/email_validator_spec.rb
|
210
222
|
- spec/lib/equality_validator_spec.rb
|