client_side_validations 2.9.2 → 2.9.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.
@@ -1,3 +1,18 @@
|
|
1
|
+
jQuery.validator.addMethod("confirmation", function(value, element) {
|
2
|
+
name = element.name.match(/\w+\[(\w+)\]/)[1];
|
3
|
+
confirmation_name = element.name.replace(name, name + '_confirmation')
|
4
|
+
confirmation_element = $('[name="'+ confirmation_name +'"]');
|
5
|
+
confirmation_element.rules('add', {
|
6
|
+
confirmer: $(element)
|
7
|
+
})
|
8
|
+
return this.optional(element) || value == confirmation_element.attr('value');
|
9
|
+
}, jQuery.validator.format("Must match confirmation."));
|
10
|
+
|
11
|
+
jQuery.validator.addMethod("confirmer", function(value, element, original_element) {
|
12
|
+
original_element.valid();
|
13
|
+
return true;
|
14
|
+
}, jQuery.validator.format(""));
|
15
|
+
|
1
16
|
jQuery.validator.addMethod("numericality", function(value, element) {
|
2
17
|
return this.optional(element) || /^(\d+(\.|,)\d+|\d+)$/.test(value);
|
3
18
|
}, jQuery.validator.format("Is not a number."));
|
@@ -6,7 +6,8 @@ module ClientSideValidations
|
|
6
6
|
|
7
7
|
def validations_to_hash(attr)
|
8
8
|
base._validators[attr.to_sym].inject({}) do |hash, validation|
|
9
|
-
|
9
|
+
validation.instance_variable_set('@options', validation.options.dup)
|
10
|
+
hash.merge!(build_validation_hash(validation.dup))
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
@@ -36,10 +36,8 @@ module ClientSideValidations
|
|
36
36
|
|
37
37
|
def convert_kind(kind, options = nil)
|
38
38
|
case kind
|
39
|
-
when 'acceptance', 'exclusion', 'inclusion', 'format'
|
39
|
+
when 'acceptance', 'exclusion', 'inclusion', 'format', 'confirmation'
|
40
40
|
kind
|
41
|
-
when 'confirmation'
|
42
|
-
'equalTo'
|
43
41
|
when 'presence'
|
44
42
|
'required'
|
45
43
|
when 'numericality'
|
@@ -80,12 +78,10 @@ module ClientSideValidations
|
|
80
78
|
validations.each do |kind, options|
|
81
79
|
kind = convert_kind(kind, options)
|
82
80
|
value = case kind
|
83
|
-
when 'acceptance', 'required', 'digits', 'numericality', 'greater_than', 'min', 'less_than', 'max', 'odd', 'even'
|
81
|
+
when 'acceptance', 'required', 'digits', 'numericality', 'greater_than', 'min', 'less_than', 'max', 'odd', 'even', 'confirmation'
|
84
82
|
true
|
85
83
|
when 'format'
|
86
84
|
options['with']
|
87
|
-
when 'equalTo'
|
88
|
-
%{[name="#{field}_confirmation"]}
|
89
85
|
when 'exclusion', 'inclusion'
|
90
86
|
options['in']
|
91
87
|
when 'islength'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: client_side_validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 35
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 2.9.
|
9
|
+
- 4
|
10
|
+
version: 2.9.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brian Cardarella
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-30 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -86,13 +86,12 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
hash:
|
89
|
+
hash: 7
|
90
90
|
segments:
|
91
91
|
- 3
|
92
92
|
- 0
|
93
93
|
- 0
|
94
|
-
|
95
|
-
version: 3.0.0.rc
|
94
|
+
version: 3.0.0
|
96
95
|
type: :development
|
97
96
|
version_requirements: *id005
|
98
97
|
- !ruby/object:Gem::Dependency
|
@@ -103,13 +102,12 @@ dependencies:
|
|
103
102
|
requirements:
|
104
103
|
- - "="
|
105
104
|
- !ruby/object:Gem::Version
|
106
|
-
hash:
|
105
|
+
hash: 7
|
107
106
|
segments:
|
108
107
|
- 3
|
109
108
|
- 0
|
110
109
|
- 0
|
111
|
-
|
112
|
-
version: 3.0.0.rc
|
110
|
+
version: 3.0.0
|
113
111
|
type: :development
|
114
112
|
version_requirements: *id006
|
115
113
|
- !ruby/object:Gem::Dependency
|
@@ -136,14 +134,14 @@ dependencies:
|
|
136
134
|
requirements:
|
137
135
|
- - "="
|
138
136
|
- !ruby/object:Gem::Version
|
139
|
-
hash:
|
137
|
+
hash: 62196417
|
140
138
|
segments:
|
141
139
|
- 2
|
142
140
|
- 0
|
143
141
|
- 0
|
144
142
|
- beta
|
145
|
-
-
|
146
|
-
version: 2.0.0.beta.
|
143
|
+
- 17
|
144
|
+
version: 2.0.0.beta.17
|
147
145
|
type: :development
|
148
146
|
version_requirements: *id008
|
149
147
|
- !ruby/object:Gem::Dependency
|