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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -3
  3. data/README.md +483 -232
  4. data/config/locales/en.yml +12 -0
  5. data/lib/flash_validators.rb +6 -0
  6. data/lib/flash_validators/matchers/ensure_valid_alpha_format_of.rb +18 -0
  7. data/lib/flash_validators/matchers/ensure_valid_alpha_numeric_format_of.rb +18 -0
  8. data/lib/flash_validators/matchers/ensure_valid_boolean_format_of.rb +2 -4
  9. data/lib/flash_validators/matchers/ensure_valid_credit_card_format_of.rb +18 -0
  10. data/lib/flash_validators/matchers/ensure_valid_currency_format_of.rb +2 -4
  11. data/lib/flash_validators/matchers/ensure_valid_email_format_of.rb +2 -4
  12. data/lib/flash_validators/matchers/ensure_valid_equality_matcher_of.rb +2 -4
  13. data/lib/flash_validators/matchers/ensure_valid_hex_format_of.rb +2 -4
  14. data/lib/flash_validators/matchers/ensure_valid_imei_format_of.rb +2 -4
  15. data/lib/flash_validators/matchers/ensure_valid_ip_format_of.rb +2 -4
  16. data/lib/flash_validators/matchers/ensure_valid_latitude_format_of.rb +2 -4
  17. data/lib/flash_validators/matchers/ensure_valid_longitude_format_of.rb +2 -4
  18. data/lib/flash_validators/matchers/ensure_valid_mac_address_format_of.rb +2 -4
  19. data/lib/flash_validators/matchers/ensure_valid_name_format_of.rb +2 -4
  20. data/lib/flash_validators/matchers/ensure_valid_password_format_of.rb +2 -4
  21. data/lib/flash_validators/matchers/ensure_valid_phone_format_of.rb +2 -4
  22. data/lib/flash_validators/matchers/ensure_valid_slug_format_of.rb +2 -4
  23. data/lib/flash_validators/matchers/ensure_valid_ssn_format_of.rb +2 -4
  24. data/lib/flash_validators/matchers/ensure_valid_url_format_of.rb +2 -4
  25. data/lib/flash_validators/matchers/ensure_valid_username_format_of.rb +2 -4
  26. data/lib/flash_validators/validators/alpha_numeric_validator.rb +17 -0
  27. data/lib/flash_validators/validators/alpha_validator.rb +19 -0
  28. data/lib/flash_validators/validators/credit_card_validator.rb +25 -0
  29. data/lib/flash_validators/validators/password_validator.rb +9 -1
  30. data/lib/flash_validators/version.rb +2 -2
  31. data/spec/lib/alpha_numeric_validator_spec.rb +61 -0
  32. data/spec/lib/alpha_validator_spec.rb +120 -0
  33. data/spec/lib/credit_card_validator_spec.rb +316 -0
  34. data/spec/lib/currency_validator_spec.rb +1 -1
  35. data/spec/lib/password_validator_spec.rb +42 -0
  36. 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.1
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-04-25 00:00:00.000000000 Z
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.2.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