judge 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,12 +1,12 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  group :development do
4
- gem "bundler", "~> 1.0.0"
4
+ gem "bundler", "~> 1.0.18"
5
5
  gem "jeweler", "~> 1.5.2"
6
6
  gem "jasmine", "~> 1.0.2"
7
- gem "rails", "~> 3.0.3"
7
+ gem "rails", "~> 3.0.10"
8
8
  gem "shoulda", "~> 2.11.3"
9
9
  gem "sqlite3-ruby", "~> 1.3.2"
10
- gem "nokogiri", "~> 1.4.4"
11
- gem "json", "~> 1.4.6"
10
+ gem "nokogiri", "~> 1.4.7"
11
+ gem "json", "~> 1.6.0"
12
12
  end
data/Gemfile.lock CHANGED
@@ -2,33 +2,33 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  abstract (1.0.0)
5
- actionmailer (3.0.3)
6
- actionpack (= 3.0.3)
7
- mail (~> 2.2.9)
8
- actionpack (3.0.3)
9
- activemodel (= 3.0.3)
10
- activesupport (= 3.0.3)
5
+ actionmailer (3.0.10)
6
+ actionpack (= 3.0.10)
7
+ mail (~> 2.2.19)
8
+ actionpack (3.0.10)
9
+ activemodel (= 3.0.10)
10
+ activesupport (= 3.0.10)
11
11
  builder (~> 2.1.2)
12
12
  erubis (~> 2.6.6)
13
- i18n (~> 0.4)
13
+ i18n (~> 0.5.0)
14
14
  rack (~> 1.2.1)
15
- rack-mount (~> 0.6.13)
16
- rack-test (~> 0.5.6)
15
+ rack-mount (~> 0.6.14)
16
+ rack-test (~> 0.5.7)
17
17
  tzinfo (~> 0.3.23)
18
- activemodel (3.0.3)
19
- activesupport (= 3.0.3)
18
+ activemodel (3.0.10)
19
+ activesupport (= 3.0.10)
20
20
  builder (~> 2.1.2)
21
- i18n (~> 0.4)
22
- activerecord (3.0.3)
23
- activemodel (= 3.0.3)
24
- activesupport (= 3.0.3)
25
- arel (~> 2.0.2)
21
+ i18n (~> 0.5.0)
22
+ activerecord (3.0.10)
23
+ activemodel (= 3.0.10)
24
+ activesupport (= 3.0.10)
25
+ arel (~> 2.0.10)
26
26
  tzinfo (~> 0.3.23)
27
- activeresource (3.0.3)
28
- activemodel (= 3.0.3)
29
- activesupport (= 3.0.3)
30
- activesupport (3.0.3)
31
- arel (2.0.9)
27
+ activeresource (3.0.10)
28
+ activemodel (= 3.0.10)
29
+ activesupport (= 3.0.10)
30
+ activesupport (3.0.10)
31
+ arel (2.0.10)
32
32
  builder (2.1.2)
33
33
  childprocess (0.1.8)
34
34
  ffi (~> 1.0.6)
@@ -48,35 +48,38 @@ GEM
48
48
  bundler (~> 1.0.0)
49
49
  git (>= 1.2.5)
50
50
  rake
51
- json (1.4.6)
51
+ json (1.6.1)
52
52
  json_pure (1.5.1)
53
- mail (2.2.15)
53
+ mail (2.2.19)
54
54
  activesupport (>= 2.3.6)
55
55
  i18n (>= 0.4.0)
56
56
  mime-types (~> 1.16)
57
57
  treetop (~> 1.4.8)
58
- mime-types (1.16)
59
- nokogiri (1.4.4)
60
- polyglot (0.3.1)
58
+ mime-types (1.17.1)
59
+ nokogiri (1.4.7)
60
+ polyglot (0.3.2)
61
61
  rack (1.2.2)
62
62
  rack-mount (0.6.14)
63
63
  rack (>= 1.0.0)
64
64
  rack-test (0.5.7)
65
65
  rack (>= 1.0)
66
- rails (3.0.3)
67
- actionmailer (= 3.0.3)
68
- actionpack (= 3.0.3)
69
- activerecord (= 3.0.3)
70
- activeresource (= 3.0.3)
71
- activesupport (= 3.0.3)
66
+ rails (3.0.10)
67
+ actionmailer (= 3.0.10)
68
+ actionpack (= 3.0.10)
69
+ activerecord (= 3.0.10)
70
+ activeresource (= 3.0.10)
71
+ activesupport (= 3.0.10)
72
72
  bundler (~> 1.0)
73
- railties (= 3.0.3)
74
- railties (3.0.3)
75
- actionpack (= 3.0.3)
76
- activesupport (= 3.0.3)
73
+ railties (= 3.0.10)
74
+ railties (3.0.10)
75
+ actionpack (= 3.0.10)
76
+ activesupport (= 3.0.10)
77
77
  rake (>= 0.8.7)
78
+ rdoc (~> 3.4)
78
79
  thor (~> 0.14.4)
79
80
  rake (0.8.7)
81
+ rdoc (3.11)
82
+ json (~> 1.4)
80
83
  rspec (2.5.0)
81
84
  rspec-core (~> 2.5.0)
82
85
  rspec-expectations (~> 2.5.0)
@@ -94,19 +97,20 @@ GEM
94
97
  shoulda (2.11.3)
95
98
  sqlite3-ruby (1.3.2)
96
99
  thor (0.14.6)
97
- treetop (1.4.9)
100
+ treetop (1.4.10)
101
+ polyglot
98
102
  polyglot (>= 0.3.1)
99
- tzinfo (0.3.26)
103
+ tzinfo (0.3.30)
100
104
 
101
105
  PLATFORMS
102
106
  ruby
103
107
 
104
108
  DEPENDENCIES
105
- bundler (~> 1.0.0)
109
+ bundler (~> 1.0.18)
106
110
  jasmine (~> 1.0.2)
107
111
  jeweler (~> 1.5.2)
108
- json (~> 1.4.6)
109
- nokogiri (~> 1.4.4)
110
- rails (~> 3.0.3)
112
+ json (~> 1.6.0)
113
+ nokogiri (~> 1.4.7)
114
+ rails (~> 3.0.10)
111
115
  shoulda (~> 2.11.3)
112
116
  sqlite3-ruby (~> 1.3.2)
data/Rakefile CHANGED
@@ -2,9 +2,10 @@ require 'rubygems'
2
2
  require 'bundler'
3
3
  require 'rake'
4
4
  require 'jeweler'
5
- require 'rake/rdoctask'
5
+ require 'rdoc/task'
6
6
  require 'jasmine'
7
7
  require 'rake/testtask'
8
+
8
9
  load 'jasmine/tasks/jasmine.rake'
9
10
  load 'lib/tasks/js_tests.rake'
10
11
 
@@ -27,7 +28,7 @@ Jeweler::Tasks.new do |gem|
27
28
  end
28
29
  Jeweler::RubygemsDotOrgTasks.new
29
30
 
30
- Rake::RDocTask.new do |rdoc|
31
+ RDoc::Task.new do |rdoc|
31
32
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
32
33
 
33
34
  rdoc.rdoc_dir = 'rdoc'
@@ -45,7 +46,7 @@ namespace :test do
45
46
 
46
47
  desc "Run javascript tests"
47
48
  task :js => ["jasmine:phantom"]
48
-
49
- desc "Run all tests"
50
- task :all => [:form, :js]
51
49
  end
50
+
51
+ desc "Run all tests"
52
+ task :test => ["test:form", "test:js"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.5.0
data/judge.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{judge}
8
- s.version = "0.4.3"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Joe Corcoran"]
12
- s.date = %q{2011-08-16}
12
+ s.date = %q{2011-11-13}
13
13
  s.description = %q{Validate forms in-place using your model validations}
14
14
  s.email = %q{joe@tribesports.com}
15
15
  s.extra_rdoc_files = [
@@ -47,6 +47,8 @@ Gem::Specification.new do |s|
47
47
  "spec/javascripts/support/jasmine_config.rb",
48
48
  "spec/javascripts/support/jasmine_runner.rb",
49
49
  "spec/javascripts/support/phantomRunner.js",
50
+ "test/dummy/Gemfile",
51
+ "test/dummy/Gemfile.lock",
50
52
  "test/dummy/Rakefile",
51
53
  "test/dummy/app/controllers/application_controller.rb",
52
54
  "test/dummy/app/controllers/foos_controller.rb",
@@ -99,7 +101,7 @@ Gem::Specification.new do |s|
99
101
  s.homepage = %q{http://github.com/joecorcoran/judge}
100
102
  s.licenses = ["MIT"]
101
103
  s.require_paths = ["lib"]
102
- s.rubygems_version = %q{1.3.7}
104
+ s.rubygems_version = %q{1.6.2}
103
105
  s.summary = %q{Simple client-side ActiveModel::Validators}
104
106
  s.test_files = [
105
107
  "spec/javascripts/support/jasmine_config.rb",
@@ -134,37 +136,36 @@ Gem::Specification.new do |s|
134
136
  ]
135
137
 
136
138
  if s.respond_to? :specification_version then
137
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
138
139
  s.specification_version = 3
139
140
 
140
141
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
141
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
142
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.18"])
142
143
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
143
144
  s.add_development_dependency(%q<jasmine>, ["~> 1.0.2"])
144
- s.add_development_dependency(%q<rails>, ["~> 3.0.3"])
145
+ s.add_development_dependency(%q<rails>, ["~> 3.0.10"])
145
146
  s.add_development_dependency(%q<shoulda>, ["~> 2.11.3"])
146
147
  s.add_development_dependency(%q<sqlite3-ruby>, ["~> 1.3.2"])
147
- s.add_development_dependency(%q<nokogiri>, ["~> 1.4.4"])
148
- s.add_development_dependency(%q<json>, ["~> 1.4.6"])
148
+ s.add_development_dependency(%q<nokogiri>, ["~> 1.4.7"])
149
+ s.add_development_dependency(%q<json>, ["~> 1.6.0"])
149
150
  else
150
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
151
+ s.add_dependency(%q<bundler>, ["~> 1.0.18"])
151
152
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
152
153
  s.add_dependency(%q<jasmine>, ["~> 1.0.2"])
153
- s.add_dependency(%q<rails>, ["~> 3.0.3"])
154
+ s.add_dependency(%q<rails>, ["~> 3.0.10"])
154
155
  s.add_dependency(%q<shoulda>, ["~> 2.11.3"])
155
156
  s.add_dependency(%q<sqlite3-ruby>, ["~> 1.3.2"])
156
- s.add_dependency(%q<nokogiri>, ["~> 1.4.4"])
157
- s.add_dependency(%q<json>, ["~> 1.4.6"])
157
+ s.add_dependency(%q<nokogiri>, ["~> 1.4.7"])
158
+ s.add_dependency(%q<json>, ["~> 1.6.0"])
158
159
  end
159
160
  else
160
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
161
+ s.add_dependency(%q<bundler>, ["~> 1.0.18"])
161
162
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
162
163
  s.add_dependency(%q<jasmine>, ["~> 1.0.2"])
163
- s.add_dependency(%q<rails>, ["~> 3.0.3"])
164
+ s.add_dependency(%q<rails>, ["~> 3.0.10"])
164
165
  s.add_dependency(%q<shoulda>, ["~> 2.11.3"])
165
166
  s.add_dependency(%q<sqlite3-ruby>, ["~> 1.3.2"])
166
- s.add_dependency(%q<nokogiri>, ["~> 1.4.4"])
167
- s.add_dependency(%q<json>, ["~> 1.4.6"])
167
+ s.add_dependency(%q<nokogiri>, ["~> 1.4.7"])
168
+ s.add_dependency(%q<json>, ["~> 1.6.0"])
168
169
  end
169
170
  end
170
171
 
@@ -2,7 +2,7 @@
2
2
  // You can find a guide and some more traditional API documentation at <http://joecorcoran.github.com/judge/>.
3
3
  // Hopefully this page will help you understand what's happening under the hood.
4
4
 
5
- /*jshint curly: true, evil: true, newcap: true, noarg: true */
5
+ /*jshint curly: true, evil: true, newcap: true, noarg: true, strict: false */
6
6
  /*global _: false, JSON: false */
7
7
 
8
8
  // The judge namespace.
@@ -10,24 +10,34 @@ var judge = judge || {};
10
10
 
11
11
  // A judge.Watcher is a DOM element wrapper that judge uses to store validation info and instance methods.
12
12
  judge.Watcher = function (element) {
13
-
13
+
14
14
  // Throw dependency errors.
15
- if (typeof window._ === "undefined") {
16
- throw new ReferenceError('[judge] Underscore.js not found');
15
+ if (typeof window._ === 'undefined') {
16
+ throw {
17
+ name: 'ReferenceError',
18
+ message: '[judge][dependency] Underscore.js not found'
19
+ };
17
20
  }
18
- if (typeof window.JSON === "undefined") {
19
- throw new ReferenceError('[judge] JSON global object not found');
21
+ if (_(window.JSON).isUndefined()) {
22
+ throw {
23
+ name: 'ReferenceError',
24
+ message: '[judge][dependency] JSON global object not found'
25
+ };
20
26
  }
21
27
 
22
28
  // Throw some constructor usage errors.
23
29
  if (_(element).isUndefined()) {
24
- throw new ReferenceError('[judge] No DOM element passed to constructor');
30
+ throw {
31
+ name: 'ReferenceError',
32
+ message: '[judge][constructor] No DOM element passed to constructor'
33
+ };
25
34
  }
35
+
26
36
  if (element.getAttribute('data-validate') === null) {
27
- throw new ReferenceError('[judge] Cannot construct Watcher for this element, use judge form builders');
28
- }
29
- if (element.form.getAttribute('data-error-messages') === null) {
30
- throw new ReferenceError('[judge] Parent form was not created using judge form helper, please amend');
37
+ throw {
38
+ name: 'ReferenceError',
39
+ message: '[judge][constructor] Cannot construct Watcher for this element, use judge form builders'
40
+ };
31
41
  }
32
42
 
33
43
  // Convenient access to this Watcher.
@@ -36,7 +46,6 @@ judge.Watcher = function (element) {
36
46
  // Watcher instance properties.
37
47
  this.element = element;
38
48
  this.validators = JSON.parse(this.element.getAttribute('data-validate'));
39
- this.defaultMessages = JSON.parse(this.element.form.getAttribute('data-error-messages'));
40
49
 
41
50
  // The `validate` instance method returns the validity of the watched element,
42
51
  // represented as an object containing the element itself and some validity information.
@@ -46,9 +55,10 @@ judge.Watcher = function (element) {
46
55
  validity = true,
47
56
  messages = [];
48
57
  _(validators).each(function(validator) {
49
- var options = validator.options;
58
+ var options = validator.options,
59
+ msgs = validator.messages;
50
60
  if (instance.element.value.length || options.allow_blank !== true) {
51
- var result = instance.validates()[validator.kind](options);
61
+ var result = instance.validates()[validator.kind](options, msgs);
52
62
  if (!result.valid && result.hasOwnProperty('messages')) {
53
63
  validity = false;
54
64
  messages.push(result.messages);
@@ -72,17 +82,17 @@ judge.Watcher.prototype.validates = function() {
72
82
 
73
83
  // Presence validator ported as closely as possible
74
84
  // from [ActiveModel::Validations::PresenceValidator](http://api.rubyonrails.org/classes/ActiveModel/Validations/PresenceValidator.html).
75
- presence: function(options) {
85
+ presence: function(options, messages) {
76
86
  if (instance.element.value.length) {
77
87
  return { valid:true };
78
88
  } else{
79
- return { valid:false, messages:[options.message || instance.defaultMessages.blank] };
89
+ return { valid:false, messages:[messages.blank] };
80
90
  }
81
91
  },
82
92
 
83
93
  // Length validator ported as closely as possible
84
94
  // from [ActiveModel::Validations::LengthValidator](http://api.rubyonrails.org/classes/ActiveModel/Validations/LengthValidator.html).
85
- length: function(options) {
95
+ length: function(options, messages) {
86
96
  var msgs = [],
87
97
  length = instance.element.value.length,
88
98
  types = {
@@ -93,8 +103,7 @@ judge.Watcher.prototype.validates = function() {
93
103
  _(types).each(function(properties, type) {
94
104
  var invalid = judge.utils.operate(length, properties.operator, options[type]);
95
105
  if (options.hasOwnProperty(type) && invalid) {
96
- var m = options[properties.message] || instance.defaultMessages[properties.message];
97
- msgs.push(judge.utils.countMsg(m, options[type]));
106
+ msgs.push(messages[properties.message]);
98
107
  }
99
108
  });
100
109
  return msgs.length ? { valid:false, messages:msgs } : { valid:true };
@@ -102,12 +111,12 @@ judge.Watcher.prototype.validates = function() {
102
111
 
103
112
  // Exclusion validator ported as closely as possible
104
113
  // from [ActiveModel::Validations::ExclusionValidator](http://api.rubyonrails.org/classes/ActiveModel/Validations/ExclusionValidator.html).
105
- exclusion: function(options) {
114
+ exclusion: function(options, messages) {
106
115
  var stringIn = _(options['in']).map(function(o) { return o.toString(); });
107
116
  if (_(stringIn).include(instance.element.value)) {
108
117
  return {
109
118
  valid:false,
110
- messages:[options.message || instance.defaultMessages.exclusion]
119
+ messages:[messages.exclusion]
111
120
  };
112
121
  } else {
113
122
  return { valid:true };
@@ -116,12 +125,12 @@ judge.Watcher.prototype.validates = function() {
116
125
 
117
126
  // Inclusion validator ported as closely as possible
118
127
  // from [ActiveModel::Validations::InclusionValidator](http://api.rubyonrails.org/classes/ActiveModel/Validations/InclusionValidator.html).
119
- inclusion: function(options) {
128
+ inclusion: function(options, messages) {
120
129
  var stringIn = _(options['in']).map(function(o) { return o.toString(); });
121
130
  if (!_(stringIn).include(instance.element.value)) {
122
131
  return {
123
132
  valid:false,
124
- messages:[options.message || instance.defaultMessages.inclusion]
133
+ messages:[messages.inclusion]
125
134
  };
126
135
  } else {
127
136
  return { valid:true };
@@ -130,7 +139,7 @@ judge.Watcher.prototype.validates = function() {
130
139
 
131
140
  // Numericality validator ported as closely as possible
132
141
  // from [ActiveModel::Validations::NumericalityValidator](http://api.rubyonrails.org/classes/ActiveModel/Validations/NumericalityValidator.html).
133
- numericality: function(options) {
142
+ numericality: function(options, messages) {
134
143
  var operators = {
135
144
  greater_than: '>',
136
145
  greater_than_or_equal_to: '>=',
@@ -143,22 +152,21 @@ judge.Watcher.prototype.validates = function() {
143
152
  parsedValue = parseFloat(value, 10);
144
153
 
145
154
  if (isNaN(Number(value))) {
146
- msgs.push(options.message || instance.defaultMessages.not_a_number);
155
+ msgs.push(messages.not_a_number);
147
156
  } else {
148
157
  if (options.odd && judge.utils.isEven(parsedValue)) {
149
- msgs.push(instance.defaultMessages.odd);
158
+ msgs.push(messages.odd);
150
159
  }
151
160
  if (options.even && judge.utils.isOdd(parsedValue)) {
152
- msgs.push(instance.defaultMessages.even);
161
+ msgs.push(messages.even);
153
162
  }
154
163
  if (options.only_integer && !judge.utils.isInt(parsedValue)) {
155
- msgs.push(instance.defaultMessages.not_an_integer);
164
+ msgs.push(messages.not_an_integer);
156
165
  }
157
166
  _(operators).each(function(operator, key) {
158
167
  var valid = judge.utils.operate(parsedValue, operators[key], parseFloat(options[key], 10));
159
168
  if (options.hasOwnProperty(key) && !valid) {
160
- var m = options.message || instance.defaultMessages[key];
161
- msgs.push(judge.utils.countMsg(m, options[key]));
169
+ msgs.push(messages[key]);
162
170
  }
163
171
  });
164
172
  }
@@ -167,19 +175,19 @@ judge.Watcher.prototype.validates = function() {
167
175
 
168
176
  // Format validator ported as closely as possible
169
177
  // from [ActiveModel::Validations::FormatValidator](http://api.rubyonrails.org/classes/ActiveModel/Validations/FormatValidator.html).
170
- format: function(options) {
178
+ format: function(options, messages) {
171
179
  var msgs = [],
172
180
  value = instance.element.value;
173
181
  if (options.hasOwnProperty('with')) {
174
182
  var withReg = judge.utils.convertRegExp(options['with']);
175
183
  if (!withReg.test(value)) {
176
- msgs.push(options.message || instance.defaultMessages.invalid);
184
+ msgs.push(messages.invalid);
177
185
  }
178
186
  }
179
187
  if (options.hasOwnProperty('without')) {
180
188
  var withoutReg = judge.utils.convertRegExp(options.without);
181
189
  if (withoutReg.test(value)) {
182
- msgs.push(options.message || instance.defaultMessages.invalid);
190
+ msgs.push(messages.invalid);
183
191
  }
184
192
  }
185
193
  return msgs.length ? { valid:false, messages:msgs } : { valid:true };
@@ -187,20 +195,20 @@ judge.Watcher.prototype.validates = function() {
187
195
 
188
196
  // Acceptance validator ported as closely as possible
189
197
  // from [ActiveModel::Validations::AcceptanceValidator](http://api.rubyonrails.org/classes/ActiveModel/Validations/AcceptanceValidator.html).
190
- acceptance: function(options) {
198
+ acceptance: function(options, messages) {
191
199
  if (instance.element.checked === true) {
192
200
  return { valid:true };
193
201
  } else {
194
202
  return {
195
203
  valid:false,
196
- messages:[options.message || instance.defaultMessages.accepted]
204
+ messages:[messages.accepted]
197
205
  };
198
206
  }
199
207
  },
200
208
 
201
209
  // Confirmation validator ported as closely as possible
202
210
  // from [ActiveModel::Validations::ConfirmationValidator](http://api.rubyonrails.org/classes/ActiveModel/Validations/ConfirmationValidator.html).
203
- confirmation: function(options) {
211
+ confirmation: function(options, messages) {
204
212
  var id = instance.element.getAttribute('id'),
205
213
  confId = id + '_confirmation',
206
214
  confElem = document.getElementById(confId);
@@ -209,7 +217,7 @@ judge.Watcher.prototype.validates = function() {
209
217
  } else {
210
218
  return {
211
219
  valid:false,
212
- messages:[options.message || instance.defaultMessages.confirmation]
220
+ messages:[messages.confirmation]
213
221
  };
214
222
  }
215
223
  }
@@ -307,20 +315,27 @@ judge.utils = {
307
315
 
308
316
  // Determines whether an object is a DOM element of the types that judge can work with.
309
317
  isValidatable: function(object) {
310
- var type = judge.utils.getObjectString(object);
311
- return (
312
- type === "HTMLInputElement" ||
313
- type === "HTMLTextAreaElement" ||
314
- type === "HTMLSelectElement"
315
- );
318
+ var type = judge.utils.getObjectString(object),
319
+ types = [
320
+ 'HTMLInputElement',
321
+ 'HTMLTextAreaElement',
322
+ 'HTMLSelectElement'
323
+ ];
324
+ return _(types).include(type);
316
325
  },
317
326
 
318
- // A way of checking isArray but including NodeList.
327
+ // A way of checking isArray, but including weird object types that are returned from collection queries.
319
328
  isCollection: function(object) {
320
- var type = judge.utils.getObjectString(object);
321
- return (
322
- type === "Array" || type === "NodeList"
323
- );
329
+ var type = judge.utils.getObjectString(object),
330
+ types = [
331
+ 'Array',
332
+ 'NodeList',
333
+ 'StaticNodeList',
334
+ 'HTMLCollection',
335
+ 'HTMLFormElement',
336
+ 'HTMLAllCollection'
337
+ ];
338
+ return _(types).include(type);
324
339
  },
325
340
 
326
341
  // Returns the object type as represented in `Object.prototype.toString`.
@@ -335,9 +350,6 @@ judge.utils = {
335
350
  return eval(input+' '+operator+' '+validInput);
336
351
  },
337
352
 
338
- // Sub the expected value into an error message.
339
- countMsg: function(message, count) { return message.replace(/\%\{count\}/, count); },
340
-
341
353
  // Some nifty numerical helpers.
342
354
  isInt: function(value) { return value === +value && value === (value|0); },
343
355
  isFloat: function(value) { return value === +value && value !== (value|0); },
@@ -367,3 +379,4 @@ judge.utils = {
367
379
  }
368
380
  };
369
381
 
382
+