roda-component 0.1.48 → 0.1.49
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 +4 -4
- data/lib/roda/component/form.rb +6 -2
- data/lib/roda/component/form/validations.rb +11 -7
- data/lib/roda/component/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e17cfb5974019243d6d710add5a5d21189a11d94
|
4
|
+
data.tar.gz: 933b965d33b37ffda33a106f727ef33a166ece83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1321db7720a3a22b05a38a61506406d25651b5dc0a33913ea90da403b4084bf16e9c40048192eabd06816e5ff6a9e54627be2e369a6b9442315a9691fc4ea27c
|
7
|
+
data.tar.gz: 2f10ddd76ae36288f098527fbb15a443bf66bae061e75a9f1b9dc63f13ea7a87baf84cfb5508c35960c01e712aa75d2483e201ece8e02555b17ed07e408111e0
|
data/lib/roda/component/form.rb
CHANGED
@@ -278,6 +278,10 @@ class Roda
|
|
278
278
|
@_attributes ||= {}
|
279
279
|
end
|
280
280
|
|
281
|
+
def validate_msg error, column
|
282
|
+
false
|
283
|
+
end
|
284
|
+
|
281
285
|
protected
|
282
286
|
|
283
287
|
def _data
|
@@ -309,7 +313,7 @@ class Roda
|
|
309
313
|
end
|
310
314
|
|
311
315
|
def _error_name key, error
|
312
|
-
case error.to_s.to_sym
|
316
|
+
validate_msg(error.to_sym, key.to_sym) || case error.to_s.to_sym
|
313
317
|
when :not_email
|
314
318
|
'Email Isn\'t Valid.'
|
315
319
|
when :not_present
|
@@ -317,7 +321,7 @@ class Roda
|
|
317
321
|
when :not_equal
|
318
322
|
'Password does not match.'
|
319
323
|
else
|
320
|
-
error
|
324
|
+
!error[/\s/] ? error.to_s.gsub(/_/, ' ').titleize : error
|
321
325
|
end
|
322
326
|
end
|
323
327
|
|
@@ -127,14 +127,18 @@ class Roda
|
|
127
127
|
# @param [Array<Symbol, Symbol>] error The error that should be returned
|
128
128
|
# when the validation fails.
|
129
129
|
def assert_present(att, error = [att, :not_present])
|
130
|
-
if
|
131
|
-
|
132
|
-
options[:key] = _options[:key] if _options.key? :key
|
133
|
-
|
134
|
-
f = klass.new(send(att).attributes, options)
|
135
|
-
assert(f.valid?, [att, f.errors])
|
130
|
+
if att.is_a? Array
|
131
|
+
att.each { |a| assert_present(a, error = [a, :not_present])}
|
136
132
|
else
|
137
|
-
|
133
|
+
if klass = _form[att]
|
134
|
+
options = {}
|
135
|
+
options[:key] = _options[:key] if _options.key? :key
|
136
|
+
|
137
|
+
f = klass.new(_attributes.send(att).attributes, options)
|
138
|
+
assert(f.valid?, [att, f.errors])
|
139
|
+
else
|
140
|
+
assert(!_attributes.send(att).to_s.empty?, error)
|
141
|
+
end
|
138
142
|
end
|
139
143
|
end
|
140
144
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roda-component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.49
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|