mini_defender 0.3.10 → 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: 3d86988a2bdf736a616cdae14ff90b0a1f094846a1a248b6602ccc5a8dc30148
4
- data.tar.gz: 27e7e95fc4c4f1d2f9aa2d6406e2f057a3b501e7dfa2f0de006cecea1bba2194
3
+ metadata.gz: e25d95f9b828e295edcfb4adea502ba8e550a097fe9f89238b37a7f281bb0ff0
4
+ data.tar.gz: 9ea7aa549e7f45bab5c1575ec9290d695459f4afdcc322608516289bb138f969
5
5
  SHA512:
6
- metadata.gz: 88bb1908e129dabc940595220e0c2f5ea7244cb08a5904f1fae9380a6c0cc0ff62465c83666dcffbaf9f83e8d0268db1223ea0e89fe9d20f0786f9c3f3f354e9
7
- data.tar.gz: 944893f26ae2e989951bdba092d4af6a5d5dcceeff89a0fdc61f6216f7dcff23cc5ff36c25b391a1937b73425554f13eeed0cfa4148fe3be3ad8427aa2725d5d
6
+ metadata.gz: f357991f889391a814f0704f811bdf31c31282f0363c28b18bfd55e183fecaa712a6771114cc5d78be7c82db282ad56bfa73a21c4b97f2e27b0c392acbf2bb25
7
+ data.tar.gz: fedb66dacbc996e7401de58f8c2bd3192bae6f4605b5d4a9a62e04b8f4e514609d800f36da9e9daa16c6b323e9893186676d78196bc1d737fddff2e032f210ba
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module HandlesValidationErrors
3
+ module MiniDefender::HandlesValidationErrors
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'active_support/core_ext/hash'
4
4
 
5
- module ValidationHelpers
5
+ module MiniDefender::ValidationHelpers
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  def validation_errors
@@ -36,9 +36,17 @@ module 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.10"
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.10
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ali Alhoshaiyan