mini_defender 0.5.2 → 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: f7eb4878351ebf49bb42e33a10f8fefd34745b4067bdf40b50180792d2883819
4
- data.tar.gz: 93ec54964db744a7f2f03a7fc23bf96b6458637d94dbfb00c4307a0e5e598964
3
+ metadata.gz: 73ce456e0b23735581871619b744d40814619b39012ebb8b1cd50367ee0e7af4
4
+ data.tar.gz: d5e71ffdebfb17149e631ad9464482209685a17b97b04b16a498a8fd0933d656
5
5
  SHA512:
6
- metadata.gz: a04dc7d2a819a0d3f8e443342900bd29db0c7e9b730128ff7d8f266f7853e52079166903997f660ef87c26c3965dd689c229bd5e533a0ff824debd3548f65417
7
- data.tar.gz: cd0109845a3f6f2ddc22c23448856124384554b6e3bbc75f1d952773c589797a421c1f7e04da15ed3461713f65ee436a8c102776ff0377dbbdeecc96da746196
6
+ metadata.gz: ae9ec903aa13fbc773146154ce692e2fb6d66c5ea6cd8a4c00597479d1811142d25c802015d7da738a79c41fd3550754e92b77ae6dd1dc85103f0ae0a8e6b9d3
7
+ data.tar.gz: 55638c4ad883417564d6f1596eb3670b01ce7b8fe85f9462f7d54b4579ed9195c0d0b787c0efeae9e81ce764df66346fbd64e7fbd6318d609044a57c0818b799
@@ -34,6 +34,10 @@ class MiniDefender::Rules::Hash < MiniDefender::Rule
34
34
  def passes?(attribute, value, validator)
35
35
  passes = value.is_a?(Hash)
36
36
 
37
+ unless passes
38
+ return false
39
+ end
40
+
37
41
  if @key_type == 'string'
38
42
  passes &= value.all? { |k, _| k.is_a?(String) }
39
43
  end
@@ -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.2"
4
+ VERSION = "0.5.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_defender
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ali Alhoshaiyan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-22 00:00:00.000000000 Z
11
+ date: 2024-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport