mini_defender 0.6.1 → 0.6.3

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: e29762e85b9cd347c9a95273d6d08d806b6adc24ff284b6ec5e4e347c4e2b910
4
- data.tar.gz: 2ea25d48682e25d311f90d33a3b5b8bacaa6720431380b34479eeede78468e3a
3
+ metadata.gz: 6ad80dedc94787965099ca97378bc2d0a7edfc7ac69ce8f78bf8f541b1c3d842
4
+ data.tar.gz: e2fcc6dba36721ae4e12d9fa37630167007612dae605099befa78248914f1616
5
5
  SHA512:
6
- metadata.gz: 6b5411b6d0bd4565a420052b3baceebff4bb1873c42c68b48f566c20533f28fd674f37f4df9bab3e6877d0959e2671fc886d1154e9d6de34508de04bae2c4778
7
- data.tar.gz: 3707890c60e1c3eccff9ab37287819a3e8997b101c5d74ef37fd2cc7bf5466d5304095607a20e8a3f2ab06de0cae22d4055b1f15a5243785511807d77680fdb6
6
+ metadata.gz: c139eb0bf32dede90dd25ecf2edbf2a3348ae4ce254c4a861f2c83c3223842e3e125c15168ba17d60e40ac8e5e8779e4f6835d9e4b2d1023f3f60d077a696756
7
+ data.tar.gz: 04edee1b20546e9277917a495c6b5fd94bb8e5939ca4da05a4cc9cb5a0be759df3eaccb40b32d41b61ca1f62bbb15fcf7e5e6751d17c08b4b5fc3a296e690f3a
@@ -13,7 +13,7 @@ class MiniDefender::Rules::DateEq < MiniDefender::Rule
13
13
  end
14
14
 
15
15
  def self.make(args)
16
- raise ArgumentError, 'Target date is required for date rules.' unless args == 1
16
+ raise ArgumentError, 'Target date is required for date rules.' unless args.length == 1
17
17
 
18
18
  self.new(args[0])
19
19
  end
@@ -7,7 +7,7 @@ module MiniDefender::ValidatesInput
7
7
  data = cleanse_data(params.to_unsafe_hash.deep_stringify_keys)
8
8
  validator = MiniDefender::Validator.new(rules, data)
9
9
  validator.validate!
10
- coerced ? validator.coerced : validator.data
10
+ coerced ? validator.coerced : validator.validated
11
11
  end
12
12
 
13
13
  private
@@ -28,7 +28,7 @@ module MiniDefender
28
28
 
29
29
  # Set default values for missing data key compared to rules
30
30
  data_rules.each do |k, set|
31
- if !@data.key?(k) || @data[k].blank?
31
+ if !@data.key?(k) || missing_value?(@data[k])
32
32
  set.filter{ |r| r.defaults?(self) }.each do |r|
33
33
  @data.merge!({k => r.default_value(self)}.flatten_keys(keep_roots: true))
34
34
  end
@@ -43,7 +43,7 @@ module MiniDefender
43
43
  value_included = true
44
44
  required = rule_set.any? { |r| r.implicit?(self) }
45
45
 
46
- if !@data.key?(k) || @data[k].blank?
46
+ if !@data.key?(k) || missing_value?(@data[k])
47
47
  rule_set.filter{ |r| r.defaults?(self) }.each do |r|
48
48
  @data.merge!({k => r.default_value(self)}.flatten_keys(keep_roots: true))
49
49
  end
@@ -188,5 +188,12 @@ module MiniDefender
188
188
 
189
189
  result
190
190
  end
191
+
192
+ def missing_value?(value)
193
+ value.nil? ||
194
+ value.is_a?(String) && value.strip.empty? ||
195
+ value.is_a?(Hash) && value.empty? ||
196
+ value.is_a?(Array) && value.empty?
197
+ end
191
198
  end
192
199
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MiniDefender
4
- VERSION = "0.6.1"
4
+ VERSION = "0.6.3"
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.6.1
4
+ version: 0.6.3
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-03-14 00:00:00.000000000 Z
11
+ date: 2024-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -219,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
219
  - !ruby/object:Gem::Version
220
220
  version: '0'
221
221
  requirements: []
222
- rubygems_version: 3.3.26
222
+ rubygems_version: 3.4.10
223
223
  signing_key:
224
224
  specification_version: 4
225
225
  summary: A small and efficient validation library for Rails and anything that uses