judge 2.0.3 → 2.0.4
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/README.md +2 -0
- data/app/assets/javascripts/judge.js +3 -3
- data/lib/judge.rb +1 -0
- data/lib/judge/controller.rb +18 -8
- data/{app/models → lib}/judge/validation.rb +0 -0
- data/lib/judge/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
[](http://travis-ci.org/joecorcoran/judge)
|
4
4
|
|
5
|
+
[](https://ci.testling.com/joecorcoran/judge)
|
6
|
+
|
5
7
|
Judge allows easy client side form validation for Rails 3 by porting many `ActiveModel::Validation` features to JavaScript. The most common validations work through JSON strings stored within HTML5 data attributes and are executed purely on the client side. Wherever you need to, Judge provides a simple interface for AJAX validations too.
|
6
8
|
|
7
9
|
## Rationale
|
@@ -1,5 +1,5 @@
|
|
1
|
-
// Judge 2.0.
|
2
|
-
// (c) 2011-
|
1
|
+
// Judge 2.0.4
|
2
|
+
// (c) 2011-2013 Joe Corcoran
|
3
3
|
// http://raw.github.com/joecorcoran/judge/master/LICENSE.txt
|
4
4
|
|
5
5
|
// This is judge.js: the JavaScript part of Judge. Judge is a client-side
|
@@ -14,7 +14,7 @@
|
|
14
14
|
var judge = root.judge = {},
|
15
15
|
_ = root._;
|
16
16
|
|
17
|
-
judge.VERSION = '2.0.
|
17
|
+
judge.VERSION = '2.0.4';
|
18
18
|
|
19
19
|
// Trying to be a bit more descriptive than the basic error types allow.
|
20
20
|
var DependencyError = function(message) {
|
data/lib/judge.rb
CHANGED
data/lib/judge/controller.rb
CHANGED
@@ -9,8 +9,8 @@ module Judge
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def validation(params)
|
12
|
-
params =
|
13
|
-
if params
|
12
|
+
params = normalized_params(params)
|
13
|
+
if params_present?(params) && params_exposed?(params)
|
14
14
|
Validation.new(params)
|
15
15
|
else
|
16
16
|
NullValidation.new(params)
|
@@ -19,12 +19,22 @@ module Judge
|
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
params[:
|
26
|
-
|
27
|
-
|
22
|
+
REQUIRED_PARAMS = %w{klass attribute value kind}
|
23
|
+
|
24
|
+
def params_exposed?(params)
|
25
|
+
Judge.config.exposed?(params[:klass], params[:attribute])
|
26
|
+
end
|
27
|
+
|
28
|
+
def params_present?(params)
|
29
|
+
params.keys == REQUIRED_PARAMS && params.values.all?
|
30
|
+
end
|
31
|
+
|
32
|
+
def normalized_params(params)
|
33
|
+
params = params.dup.keep_if { |k| REQUIRED_PARAMS.include?(k) }
|
34
|
+
params[:klass] = find_klass(params[:klass]) if params[:klass]
|
35
|
+
params[:attribute] = params[:attribute].to_sym if params[:attribute]
|
36
|
+
params[:value] = URI.decode(params[:value]) if params[:value]
|
37
|
+
params[:kind] = params[:kind].to_sym if params[:kind]
|
28
38
|
params
|
29
39
|
end
|
30
40
|
|
File without changes
|
data/lib/judge/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: judge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -131,7 +131,6 @@ extra_rdoc_files: []
|
|
131
131
|
files:
|
132
132
|
- app/assets/javascripts/judge.js
|
133
133
|
- app/controllers/judge/validations_controller.rb
|
134
|
-
- app/models/judge/validation.rb
|
135
134
|
- config/routes.rb
|
136
135
|
- lib/generators/judge/install/install_generator.rb
|
137
136
|
- lib/judge/config.rb
|
@@ -142,6 +141,7 @@ files:
|
|
142
141
|
- lib/judge/html.rb
|
143
142
|
- lib/judge/message_collection.rb
|
144
143
|
- lib/judge/message_config.rb
|
144
|
+
- lib/judge/validation.rb
|
145
145
|
- lib/judge/validator.rb
|
146
146
|
- lib/judge/validator_collection.rb
|
147
147
|
- lib/judge/version.rb
|