mini_defender 0.5.3 → 0.5.4

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: 73ce456e0b23735581871619b744d40814619b39012ebb8b1cd50367ee0e7af4
4
+ data.tar.gz: d5e71ffdebfb17149e631ad9464482209685a17b97b04b16a498a8fd0933d656
5
5
  SHA512:
6
- metadata.gz: d5493f26115c5833ca54f55d4d551751fcd975b6a3c3c4ee8fe53b197f9c78c088d545d60751e026b22598549c3561593023b39b5cc17c8256d952e84f9b4ea1
7
- data.tar.gz: ae08110a394548937b2ee193e583399e994f8cb82b6d828c5768d5ffb7cbfaaf663996ec0d9ad61d0d25c06de61d00dad06f1f722640800949dd5142cb1545ef
6
+ metadata.gz: ae9ec903aa13fbc773146154ce692e2fb6d66c5ea6cd8a4c00597479d1811142d25c802015d7da738a79c41fd3550754e92b77ae6dd1dc85103f0ae0a8e6b9d3
7
+ data.tar.gz: 55638c4ad883417564d6f1596eb3670b01ce7b8fe85f9462f7d54b4579ed9195c0d0b787c0efeae9e81ce764df66346fbd64e7fbd6318d609044a57c0818b799
@@ -1,12 +1,28 @@
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 coerce(value)
13
+ value.to_s
14
+ end
15
+
8
16
  def passes?(attribute, value, validator)
9
- value.is_a?(String)
17
+ if @mode == 'relaxed'
18
+ value.is_a?(String) ||
19
+ value.is_a?(Integer) ||
20
+ value.is_a?(Float) ||
21
+ value.is_a?(FalseClass) ||
22
+ value.is_a?(TrueClass)
23
+ else
24
+ value.is_a?(String)
25
+ end
10
26
  end
11
27
 
12
28
  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.4"
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.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ali Alhoshaiyan