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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87731b96739bb1b69873c678f424ab5a9e5edf8ff2c084803582865fb6ce353b
4
- data.tar.gz: 0e2c1516a69cfa689cccea7a2013bec0817ea9790831986fbe2fff79f51945c0
3
+ metadata.gz: 530d1373078938df751149e2e02ccad634c4575e636374fc532a523ad0a1a7d0
4
+ data.tar.gz: 56410958ff3a856d9fdee8f001346bfe6b4851c4b7c7c4df45adb4f0922754bd
5
5
  SHA512:
6
- metadata.gz: d5493f26115c5833ca54f55d4d551751fcd975b6a3c3c4ee8fe53b197f9c78c088d545d60751e026b22598549c3561593023b39b5cc17c8256d952e84f9b4ea1
7
- data.tar.gz: ae08110a394548937b2ee193e583399e994f8cb82b6d828c5768d5ffb7cbfaaf663996ec0d9ad61d0d25c06de61d00dad06f1f722640800949dd5142cb1545ef
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
- value.is_a?(String)
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MiniDefender
4
- VERSION = "0.5.3"
4
+ VERSION = "0.5.5"
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.5.3
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ali Alhoshaiyan