judge 2.1.1 → 3.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fcf1e3ed1bb5500b69d1cc9e5074e56f43e86a46
4
- data.tar.gz: 9536e4c10547ccf7abbcb7dd6e83699096f7c282
3
+ metadata.gz: 0b0741ccd453132180a996df4d09f44547df293e
4
+ data.tar.gz: 3e0dc614b53717b745891d68ab496eeabada29a0
5
5
  SHA512:
6
- metadata.gz: 208177747be57442d0ff59bf79b86ceda1a675c40ae2d28f9b883a40da6b7fd8f7281b746074138e3c9e885d47a78ec31b29f424bd971f3816527e9c9156b90f
7
- data.tar.gz: b7893ca20ab01d91c325de6585642177af687a2065ca2931543f45a73459e8628063bfd535f77bbef8cd7916eb3673ba9abc9ebfaeacfa35c5aad8d99b387921
6
+ metadata.gz: 488b9fabe5582a64cf36c4093e183e721ec30ed0c94af54e4818a1a31260b74c154e12f4f5b4c1f45111734f28cb5eb8cbf29afe90f02b22700fa2a838b83cc6
7
+ data.tar.gz: fe944398c1c1affc47c04747329c078f7cc8d41686bdc1819660e74b7b1d51e17730668beb367a2b04290596fc154cb404ca5b3a12bd547b39c6e7ce3760080e
data/README.md CHANGED
@@ -12,7 +12,8 @@ In many cases it would be simpler to safely expose the validation information fr
12
12
 
13
13
  ## Installation
14
14
 
15
- Judge supports Rails >= 3.1.
15
+ Judge supports Rails 5.0+.
16
+ If you require Rails 4 support, please use version 2.1.x.
16
17
 
17
18
  Judge relies on [Underscore.js](underscore) in general and [JSON2.js](json2) for browsers that lack proper JSON support. If your application already makes use of these files, you can safely ignore the versions provided with Judge.
18
19
 
@@ -116,7 +117,48 @@ end
116
117
  * uniqueness;
117
118
  * any `EachValidator` that you have written, provided you add a JavaScript version too and add it to `judge.eachValidators`.
118
119
 
119
- The *allow_blank* option is available everywhere it should be. Error messages are looked up according to the [Rails i18n API](http://guides.rubyonrails.org/i18n.html#translations-for-active-record-models).
120
+ The *allow_blank* option is available everywhere it should be.
121
+
122
+ ### Error messages
123
+ Error messages are looked up according to the [Rails i18n API](http://guides.rubyonrails.org/i18n.html#error-message-interpolation).
124
+
125
+ To override error messages, add entries to `config/locales/en.yml` for the messages you'd like to customize. Here's an example with Rails default values:
126
+ ```
127
+ en:
128
+ errors:
129
+ format: "%{attribute} %{message}"
130
+ messages:
131
+ accepted: must be accepted
132
+ blank: can't be blank
133
+ present: must be blank
134
+ confirmation: doesn't match %{attribute}
135
+ empty: can't be empty
136
+ equal_to: must be equal to %{count}
137
+ even: must be even
138
+ exclusion: is reserved
139
+ greater_than: must be greater than %{count}
140
+ greater_than_or_equal_to: must be greater than or equal to %{count}
141
+ inclusion: is not included in the list
142
+ invalid: is invalid
143
+ less_than: must be less than %{count}
144
+ less_than_or_equal_to: must be less than or equal to %{count}
145
+ model_invalid: "Validation failed: %{errors}"
146
+ not_a_number: is not a number
147
+ not_an_integer: must be an integer
148
+ odd: must be odd
149
+ required: must exist
150
+ taken: has already been taken
151
+ too_long:
152
+ one: is too long (maximum is 1 character)
153
+ other: is too long (maximum is %{count} characters)
154
+ too_short:
155
+ one: is too short (minimum is 1 character)
156
+ other: is too short (minimum is %{count} characters)
157
+ wrong_length:
158
+ one: is the wrong length (should be 1 character)
159
+ other: is the wrong length (should be %{count} characters)
160
+ other_than: must be other than %{count}
161
+ ```
120
162
 
121
163
  ## Validating uniqueness
122
164
 
@@ -321,6 +363,6 @@ $ bundle exec rake appraisal
321
363
 
322
364
  ## Credit
323
365
 
324
- Created by [Joe Corcoran](mailto:joecorcoran@gmail.com), whose [blog](http://blog.joecorcoran.co.uk) and [tweets](http://twitter.com/josephcorcoran) you can read on the world wide internet. Thank you to every user, email corresponder and pull request submitter.
366
+ Created by [Joe Corcoran](https://corcoran.io). Thank you to every user, email corresponder and pull request submitter.
325
367
 
326
368
  [Released under an MIT license](https://github.com/joecorcoran/judge/blob/master/LICENSE.txt).
@@ -8,7 +8,7 @@ module Judge
8
8
  @@ignore_unsupported_validators = false
9
9
 
10
10
  def expose(klass, *attributes)
11
- attrs = (@@exposed[klass] ||= [])
11
+ attrs = (@@exposed[klass.name] ||= [])
12
12
  attrs.concat(attributes).uniq!
13
13
  end
14
14
 
@@ -17,15 +17,15 @@ module Judge
17
17
  end
18
18
 
19
19
  def exposed?(klass, attribute)
20
- @@exposed.has_key?(klass) && @@exposed[klass].include?(attribute)
20
+ @@exposed.has_key?(klass.name) && @@exposed[klass.name].include?(attribute)
21
21
  end
22
22
 
23
23
  def unexpose(klass, *attributes)
24
24
  attributes.each do |a|
25
- @@exposed[klass].delete(a)
25
+ @@exposed[klass.name].delete(a)
26
26
  end
27
- if attributes.empty? || @@exposed[klass].empty?
28
- @@exposed.delete(klass)
27
+ if attributes.empty? || @@exposed[klass.name].empty?
28
+ @@exposed.delete(klass.name)
29
29
  end
30
30
  end
31
31
 
@@ -45,4 +45,4 @@ module Judge
45
45
  def self.configure(&block)
46
46
  Config.instance.instance_eval(&block)
47
47
  end
48
- end
48
+ end
@@ -4,7 +4,7 @@ module Judge
4
4
 
5
5
  include Judge::Html
6
6
 
7
- %w{text_field text_area password_field email_field}.each do |type|
7
+ %w{text_field text_area password_field email_field telephone_field}.each do |type|
8
8
  helper = <<-END
9
9
  def #{type}(method, options = {})
10
10
  add_validate_attr!(self.object, method, options)
@@ -33,7 +33,7 @@ module Judge
33
33
  end
34
34
 
35
35
  def as_json(options = {})
36
- record.errors.get(@attribute) || []
36
+ record.errors[@attribute] || []
37
37
  end
38
38
  end
39
39
 
@@ -51,4 +51,4 @@ module Judge
51
51
  end
52
52
  end
53
53
 
54
- end
54
+ end
@@ -1,3 +1,3 @@
1
1
  module Judge
2
- VERSION = '2.1.1'
2
+ VERSION = '3.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: judge
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Corcoran
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-24 00:00:00.000000000 Z
11
+ date: 2018-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.1'
19
+ version: '5.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '3.1'
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec-rails
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  version: '0'
159
159
  requirements: []
160
160
  rubyforge_project:
161
- rubygems_version: 2.4.3
161
+ rubygems_version: 2.6.13
162
162
  signing_key:
163
163
  specification_version: 4
164
164
  summary: Client side validation for Rails