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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad6c2b14f1d526e6b5f8853508477823396d086a
4
- data.tar.gz: 43638f0a8d10315bcff452763f2521cf7806eb13
3
+ metadata.gz: e17cfb5974019243d6d710add5a5d21189a11d94
4
+ data.tar.gz: 933b965d33b37ffda33a106f727ef33a166ece83
5
5
  SHA512:
6
- metadata.gz: 32b2ef520e19cc645682e4605764b3eaa533c0b79872bc9cccc9f3be99b11fca0b370d53b6a5cd2d43aa36d1bb2352329189cb79f201d0d197da1143ff8e1e32
7
- data.tar.gz: 10cb7029004e83e18fd3ac5a58102a96d78ca0ffd422baaa2aca1540b7106495a54acff89dd9373f0b0b5eb60135d3c542660740b52df6b4050a35a495f8d869
6
+ metadata.gz: 1321db7720a3a22b05a38a61506406d25651b5dc0a33913ea90da403b4084bf16e9c40048192eabd06816e5ff6a9e54627be2e369a6b9442315a9691fc4ea27c
7
+ data.tar.gz: 2f10ddd76ae36288f098527fbb15a443bf66bae061e75a9f1b9dc63f13ea7a87baf84cfb5508c35960c01e712aa75d2483e201ece8e02555b17ed07e408111e0
@@ -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 klass = _form[att]
131
- options = {}
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
- assert(!send(att).to_s.empty?, error)
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
 
@@ -1,5 +1,5 @@
1
1
  class Roda
2
2
  class Component
3
- VERSION = "0.1.48"
3
+ VERSION = "0.1.49"
4
4
  end
5
5
  end
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.48
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-26 00:00:00.000000000 Z
11
+ date: 2015-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal