guardsjs-rails 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/assets/javascripts/guards.js +111 -8
- data/lib/guardsjs-rails/version.rb +1 -1
- metadata +13 -20
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4ecaddb03b89008086fe01b4fb8a192361d7932c
|
4
|
+
data.tar.gz: 7ac29aeec4958754ce9287e3b4a394c784ad4179
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e46265182f15c0aa8428589ee3d55f4083e5ae3ff6bb8ce116c3c569b28d8cb068cb1378cee554bcbed984b576eac40a37e84f5db78c35dddc5818a12b88cbfe
|
7
|
+
data.tar.gz: 3350e7fdf53ae9c936a0607ef7867701e5d5bd31a488e2d51d9bec0151122fe0f48b57106ab77497a80b71b76227e52c55bf3b226bf556a263cf7163c173df30
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* Guards JavaScript jQuery Plugin v1.3.
|
2
|
+
* Guards JavaScript jQuery Plugin v1.3.1
|
3
3
|
* https://github.com/on-site/guards.js
|
4
4
|
*
|
5
5
|
* Copyright 2010-2014, On-Site.com, http://www.on-site.com/
|
@@ -8,7 +8,7 @@
|
|
8
8
|
* Includes code for email and phone number validation from the jQuery
|
9
9
|
* Validation plugin. http://docs.jquery.com/Plugins/Validation
|
10
10
|
*
|
11
|
-
* Date:
|
11
|
+
* Date: Sun Apr 13 13:33:25 2014 -0700
|
12
12
|
*/
|
13
13
|
|
14
14
|
/**
|
@@ -48,7 +48,7 @@
|
|
48
48
|
return $.guards.add(selector);
|
49
49
|
};
|
50
50
|
|
51
|
-
$.guard.version = "1.3.
|
51
|
+
$.guard.version = "1.3.1";
|
52
52
|
|
53
53
|
$.Guards = function() {
|
54
54
|
var self = this;
|
@@ -151,8 +151,34 @@
|
|
151
151
|
* </p>
|
152
152
|
* </div>
|
153
153
|
* </div>
|
154
|
+
*
|
155
|
+
* <p>
|
156
|
+
* As of version 1.3.1, the allowed words can be specified via an object with a string property
|
157
|
+
* named <code>words</code> delimited by spaces by default, or delimited with the
|
158
|
+
* <code>delimiter</code> property. This is primarily to support the <a href="data_attributes.html">data attributes</a>
|
159
|
+
* form of guards.
|
160
|
+
* </p>
|
161
|
+
*
|
162
|
+
* <div class="example">
|
163
|
+
* <div class="display">
|
164
|
+
* <script>
|
165
|
+
* $.guard(".primary-color-2").using("allow", { words: "red yellow blue" });
|
166
|
+
* $.guard(".country").using("allow", { words: "United States,Canada", delimiter: "," });
|
167
|
+
* </script>
|
168
|
+
*
|
169
|
+
* <p>
|
170
|
+
* <input class="primary-color" type="text" /><br />
|
171
|
+
* <small>Allowed values: red, yellow, blue</small>
|
172
|
+
* </p>
|
173
|
+
*
|
174
|
+
* <p>
|
175
|
+
* <input class="country" type="text" /><br />
|
176
|
+
* <small>Allowed values: United States, Canada</small>
|
177
|
+
* </p>
|
178
|
+
* </div>
|
179
|
+
* </div>
|
154
180
|
*/
|
155
|
-
this.name("allow").using(this.aggregate(this.isAllValid, this.isAllowed)).message(this.
|
181
|
+
this.name("allow").using(this.aggregate(this.isAllValid, this.isAllowed)).message(this.wordsArrayMessage("Please enter one of: #{0}."));
|
156
182
|
|
157
183
|
/**
|
158
184
|
* @page Named Guards
|
@@ -226,8 +252,34 @@
|
|
226
252
|
* </p>
|
227
253
|
* </div>
|
228
254
|
* </div>
|
255
|
+
*
|
256
|
+
* <p>
|
257
|
+
* As of version 1.3.1, the disallowed words can be specified via an object with a string property
|
258
|
+
* named <code>words</code> delimited by spaces by default, or delimited with the
|
259
|
+
* <code>delimiter</code> property. This is primarily to support the <a href="data_attributes.html">data attributes</a>
|
260
|
+
* form of guards.
|
261
|
+
* </p>
|
262
|
+
*
|
263
|
+
* <div class="example">
|
264
|
+
* <div class="display">
|
265
|
+
* <script>
|
266
|
+
* $.guard(".not-primary-color-2").using("disallow", { words: "red yellow blue" });
|
267
|
+
* $.guard(".not-country").using("disallow", { words: "United States,Canada", delimiter: "," });
|
268
|
+
* </script>
|
269
|
+
*
|
270
|
+
* <p>
|
271
|
+
* <input class="not-primary-color-2" type="text" /><br />
|
272
|
+
* <small>Disallowed values: red, yellow, blue</small>
|
273
|
+
* </p>
|
274
|
+
*
|
275
|
+
* <p>
|
276
|
+
* <input class="not-country" type="text" /><br />
|
277
|
+
* <small>Disallowed values: United States, Canada</small>
|
278
|
+
* </p>
|
279
|
+
* </div>
|
280
|
+
* </div>
|
229
281
|
*/
|
230
|
-
this.name("disallow").using(this.aggregate(this.isAllValid, this.isDisallowed)).message(this.
|
282
|
+
this.name("disallow").using(this.aggregate(this.isAllValid, this.isDisallowed)).message(this.wordsArrayMessage("Please don't enter: #{0}."));
|
231
283
|
|
232
284
|
/**
|
233
285
|
* @page Named Guards
|
@@ -561,6 +613,25 @@
|
|
561
613
|
* </p>
|
562
614
|
* </div>
|
563
615
|
* </div>
|
616
|
+
*
|
617
|
+
* <p>
|
618
|
+
* As of version 1.3.1, the regex can be specified via an object with a string property named
|
619
|
+
* <code>pattern</code>. This is primarily to support the <a href="data_attributes.html">data attributes</a>
|
620
|
+
* form of guards.
|
621
|
+
* </p>
|
622
|
+
*
|
623
|
+
* <div class="example">
|
624
|
+
* <div class="display">
|
625
|
+
* <script>
|
626
|
+
* $.guard(".regex2").using("regex", { pattern: "^abc\\d{1,3}$" });
|
627
|
+
* </script>
|
628
|
+
*
|
629
|
+
* <p>
|
630
|
+
* <input class="regex2" type="text" /><br />
|
631
|
+
* <small>abc with 1-3 digits is required, like 'abc123'</small>
|
632
|
+
* </p>
|
633
|
+
* </div>
|
634
|
+
* </div>
|
564
635
|
*/
|
565
636
|
this.name("regex").using(this.aggregate(this.isAllValid, this.matchesRegex)).message("Please enter valid input.");
|
566
637
|
|
@@ -674,7 +745,7 @@
|
|
674
745
|
* This version of guards.js library as a string, like <code>"1.0.0"</code>.
|
675
746
|
* </p>
|
676
747
|
*/
|
677
|
-
$.Guards.prototype.version = "1.3.
|
748
|
+
$.Guards.prototype.version = "1.3.1";
|
678
749
|
|
679
750
|
$.Guards.prototype.parentContext = function(element) {
|
680
751
|
var $element = $(element);
|
@@ -741,6 +812,16 @@
|
|
741
812
|
return result;
|
742
813
|
};
|
743
814
|
|
815
|
+
$.Guards.prototype.wordsArrayMessage = function(formatting) {
|
816
|
+
var self = this;
|
817
|
+
var formattingFn = this.arrayMessage(formatting);
|
818
|
+
|
819
|
+
return function(array) {
|
820
|
+
array = self.getWordsArray(array);
|
821
|
+
return formattingFn(array);
|
822
|
+
};
|
823
|
+
};
|
824
|
+
|
744
825
|
$.Guards.prototype.arrayMessage = function(formatting) {
|
745
826
|
var self = this;
|
746
827
|
|
@@ -1007,6 +1088,23 @@
|
|
1007
1088
|
return false;
|
1008
1089
|
};
|
1009
1090
|
|
1091
|
+
/**
|
1092
|
+
* The given object will either already be an array, or will be an
|
1093
|
+
* object describing the array (a string words property with
|
1094
|
+
* implicitly " " delimiter, or an explicit delimiter property).
|
1095
|
+
*/
|
1096
|
+
$.Guards.prototype.getWordsArray = function(obj) {
|
1097
|
+
if ($.type(obj) === "object" && !this.isNullOrUndefined(obj.words)) {
|
1098
|
+
return obj.words.split(obj.delimiter || " ");
|
1099
|
+
}
|
1100
|
+
|
1101
|
+
if ($.type(obj) === "array") {
|
1102
|
+
return obj;
|
1103
|
+
}
|
1104
|
+
|
1105
|
+
throw new Error("Invalid type, expecting array or object with words property and optional delimiter property, got " + $.type(obj));
|
1106
|
+
};
|
1107
|
+
|
1010
1108
|
/**
|
1011
1109
|
* Return whether or not the value exists in the given allowed
|
1012
1110
|
* list. The allowed parameter must be an array of valid values.
|
@@ -1015,6 +1113,7 @@
|
|
1015
1113
|
*/
|
1016
1114
|
$.Guards.prototype.isAllowed = function(value, allowed) {
|
1017
1115
|
value = $.trim(value);
|
1116
|
+
allowed = this.getWordsArray(allowed);
|
1018
1117
|
return $.inArray(value, $.map(allowed, function(x) { return $.trim("" + x); })) !== -1;
|
1019
1118
|
};
|
1020
1119
|
|
@@ -1305,7 +1404,11 @@
|
|
1305
1404
|
* Validates the given value matches the given regex.
|
1306
1405
|
*/
|
1307
1406
|
$.Guards.prototype.matchesRegex = function(value, regex) {
|
1308
|
-
if ($.type(regex)
|
1407
|
+
if ($.type(regex) === "object" && regex.pattern) {
|
1408
|
+
regex = new RegExp(regex.pattern);
|
1409
|
+
}
|
1410
|
+
|
1411
|
+
if ($.type(regex) !== "regexp") {
|
1309
1412
|
throw new Error("The regex must be provided as an option!");
|
1310
1413
|
}
|
1311
1414
|
|
@@ -1346,7 +1449,7 @@
|
|
1346
1449
|
*
|
1347
1450
|
* Example: $.guards.add(".validPhone").using("phoneUS");
|
1348
1451
|
* Example: $.guards.add(".custom").using(function(value, element) {
|
1349
|
-
* return value
|
1452
|
+
* return value !== "invalid";
|
1350
1453
|
* }).message("Don't use the keyword 'invalid'.");
|
1351
1454
|
* Example: $.guards.add(".custom").grouped().using(function(values, elements) {
|
1352
1455
|
* return $.inArray("invalid", values) == -1;
|
metadata
CHANGED
@@ -1,36 +1,33 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guardsjs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
5
|
-
prerelease:
|
4
|
+
version: 1.3.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Mike Virata-Stone
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-13 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: railties
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '3.0'
|
22
|
-
- - <
|
20
|
+
- - "<"
|
23
21
|
- !ruby/object:Gem::Version
|
24
22
|
version: '5.0'
|
25
23
|
type: :runtime
|
26
24
|
prerelease: false
|
27
25
|
version_requirements: !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
26
|
requirements:
|
30
|
-
- -
|
27
|
+
- - ">="
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: '3.0'
|
33
|
-
- - <
|
30
|
+
- - "<"
|
34
31
|
- !ruby/object:Gem::Version
|
35
32
|
version: '5.0'
|
36
33
|
description: This gem wraps the guards.js jQuery validation library as a Rails asset
|
@@ -41,35 +38,31 @@ executables: []
|
|
41
38
|
extensions: []
|
42
39
|
extra_rdoc_files: []
|
43
40
|
files:
|
44
|
-
- lib/guardsjs-rails/version.rb
|
45
|
-
- lib/guardsjs-rails.rb
|
46
41
|
- app/assets/javascripts/guards.js
|
42
|
+
- lib/guardsjs-rails.rb
|
43
|
+
- lib/guardsjs-rails/version.rb
|
47
44
|
homepage: http://guardsjs.com/
|
48
45
|
licenses:
|
49
46
|
- MIT
|
47
|
+
metadata: {}
|
50
48
|
post_install_message:
|
51
49
|
rdoc_options: []
|
52
50
|
require_paths:
|
53
51
|
- lib
|
54
52
|
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
53
|
requirements:
|
57
|
-
- -
|
54
|
+
- - ">="
|
58
55
|
- !ruby/object:Gem::Version
|
59
56
|
version: '0'
|
60
|
-
segments:
|
61
|
-
- 0
|
62
|
-
hash: 986596030085484236
|
63
57
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
-
none: false
|
65
58
|
requirements:
|
66
|
-
- -
|
59
|
+
- - ">="
|
67
60
|
- !ruby/object:Gem::Version
|
68
61
|
version: '0'
|
69
62
|
requirements: []
|
70
63
|
rubyforge_project:
|
71
|
-
rubygems_version:
|
64
|
+
rubygems_version: 2.2.2
|
72
65
|
signing_key:
|
73
|
-
specification_version:
|
66
|
+
specification_version: 4
|
74
67
|
summary: Rails asset gem for guards.js.
|
75
68
|
test_files: []
|