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 +4 -4
- data/lib/mini_defender/validation_helpers.rb +11 -3
- data/lib/mini_defender/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e25d95f9b828e295edcfb4adea502ba8e550a097fe9f89238b37a7f281bb0ff0
|
4
|
+
data.tar.gz: 9ea7aa549e7f45bab5c1575ec9290d695459f4afdcc322608516289bb138f969
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
42
|
-
errors.each { |e| yield(e) }
|
50
|
+
field_errors(field).each { |e| yield(e) }
|
43
51
|
end
|
44
52
|
end
|