mini_defender 0.3.11 → 0.3.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cdbaf1ca9c6da27dc125f3585d2c4e73e638794cb87d8ad5f983a9532e85af6
4
- data.tar.gz: 440a52ff11491cefacc033e958d1b43b7d6d7805cbff618a5f718d1dabe83cde
3
+ metadata.gz: e25d95f9b828e295edcfb4adea502ba8e550a097fe9f89238b37a7f281bb0ff0
4
+ data.tar.gz: 9ea7aa549e7f45bab5c1575ec9290d695459f4afdcc322608516289bb138f969
5
5
  SHA512:
6
- metadata.gz: 462bbdac39c0a28b1596243c1a0e252217f191ef32bf135efa661692a9f58e280da94a550ab7c3dddcae621f6b5b65fb81ba691ae5d6dffdf917a2a6f8c18009
7
- data.tar.gz: f61ca0aab03eaa52e315dab83c83de263882d2281adcdb4ce7d73d03132f4909353b2c174f7d6207797f1fc949dfb2257695645c17d39f5ca31fb4dcbe6e4290
6
+ metadata.gz: f357991f889391a814f0704f811bdf31c31282f0363c28b18bfd55e183fecaa712a6771114cc5d78be7c82db282ad56bfa73a21c4b97f2e27b0c392acbf2bb25
7
+ data.tar.gz: fedb66dacbc996e7401de58f8c2bd3192bae6f4605b5d4a9a62e04b8f4e514609d800f36da9e9daa16c6b323e9893186676d78196bc1d737fddff2e032f210ba
@@ -36,9 +36,17 @@ module MiniDefender::ValidationHelpers
36
36
  end
37
37
 
38
38
  def field_errors(field)
39
- raise ArgumentError, 'Expected a block.' unless block_given?
39
+ # Transform Rails foo[bar] convention to foo.bar
40
+ field = field.gsub('[', '.').gsub(']', '')
41
+
42
+ validation_errors[field] || []
43
+ end
44
+
45
+ def render_field_errors(field)
46
+ unless block_given?
47
+ raise ArgumentError, 'Expected a block.'
48
+ end
40
49
 
41
- errors = validation_errors[field] || []
42
- errors.each { |e| yield(e) }
50
+ field_errors(field).each { |e| yield(e) }
43
51
  end
44
52
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MiniDefender
4
- VERSION = "0.3.11"
4
+ VERSION = "0.3.12"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_defender
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ali Alhoshaiyan