mini_defender 0.5.3 → 0.5.5
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/rules/string.rb +21 -1
- 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: 530d1373078938df751149e2e02ccad634c4575e636374fc532a523ad0a1a7d0
|
4
|
+
data.tar.gz: 56410958ff3a856d9fdee8f001346bfe6b4851c4b7c7c4df45adb4f0922754bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13715f920cc17e0374f87b02be2d613b9789e8c0f09b648e055ec8580408dfa0133e698c518019b9f8bd69b4b9f772d942e1556b025e701b53bad3b9a71d9efc
|
7
|
+
data.tar.gz: bf50307441669882e6dac6688985cf41f4214f6f5ea3506c396ef742465b46fe8e8f3e6f320f4bd9e89f59cac9b07b0c67cb9030f703027ee971717fa2ab658a
|
@@ -1,12 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class MiniDefender::Rules::String < MiniDefender::Rule
|
4
|
+
def initialize(mode = 'strict')
|
5
|
+
@mode = mode
|
6
|
+
end
|
7
|
+
|
4
8
|
def self.signature
|
5
9
|
'string'
|
6
10
|
end
|
7
11
|
|
12
|
+
def self.make(args)
|
13
|
+
new(args[0] || 'strict')
|
14
|
+
end
|
15
|
+
|
16
|
+
def coerce(value)
|
17
|
+
value.to_s
|
18
|
+
end
|
19
|
+
|
8
20
|
def passes?(attribute, value, validator)
|
9
|
-
|
21
|
+
if @mode == 'relaxed'
|
22
|
+
value.is_a?(String) ||
|
23
|
+
value.is_a?(Integer) ||
|
24
|
+
value.is_a?(Float) ||
|
25
|
+
value.is_a?(FalseClass) ||
|
26
|
+
value.is_a?(TrueClass)
|
27
|
+
else
|
28
|
+
value.is_a?(String)
|
29
|
+
end
|
10
30
|
end
|
11
31
|
|
12
32
|
def message(attribute, value, validator)
|