hashy_validator 0.1.5 → 0.1.6

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: 65bbe593f0a313de084f7bd4a7ab23075422a068a7bea5dc6903f55a7243b09e
4
- data.tar.gz: b86b243a6e39958a38b8c51bd1d2ce2644e0581a6929956faf74d8c83cab2a34
3
+ metadata.gz: 68ad620a19feee19aa4ddb694d131b65bd730e36d1241c68c01a56685921a7df
4
+ data.tar.gz: f58c1ae578d2792fc6951a183a411a027e8f79c56c73d91d7ff44ca0e449451f
5
5
  SHA512:
6
- metadata.gz: af7fd7055e2bf2462ae5784668f7c42d502abfd293e72c4ded6d17d5694182b92342ffb3f22a45063534d81ad53b15c0652092e66490abe46a8428a8acfba166
7
- data.tar.gz: 74a8d08f9409cd379a2be4af5a82118323ed36dbfb097cddac2fc9b8860348efb37d401c18da6040dbd04bc70adde05483dd72d600fc716d1c58af1d5c7fbd2b
6
+ metadata.gz: d46e4caa6c10b0bc0b540ec70605946d20994b1de70eb72941999e29438ebff36d6b48aa67ec6d226411712d24a5731b5a7a83aa5eb7a784c3b907c89a62d590
7
+ data.tar.gz: 075c4f733dd7c482bdef0bb47795035bcec587d14ae85803ed21ae4de5e85327f85e6866925c2204fe84961acaf2059a9a2796544e43de1492773629379914b6
data/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ### [0.1.6](https://www.github.com/flecto-io/hashy-validator/compare/v0.1.5...v0.1.6) (2024-09-05)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * handle nil object and boolean cases ([74deb27](https://www.github.com/flecto-io/hashy-validator/commit/74deb276c08c4ebb85954cb6d1fe098308f914a6))
14
+
8
15
  ### [0.1.5](https://www.github.com/flecto-io/hashy-validator/compare/v0.1.4...v0.1.5) (2024-09-05)
9
16
 
10
17
 
@@ -5,7 +5,7 @@ class HashyObjectValidator < ActiveModel::EachValidator
5
5
  instance_value = HashyValueValidator.new(value, options)
6
6
 
7
7
  # Do not validate empty hash
8
- return if instance_value.value.keys.empty?
8
+ return if instance_value.value.blank?
9
9
 
10
10
  unless instance_value.valid?
11
11
  record.errors.add(attribute, instance_value.reason)
@@ -21,19 +21,9 @@ class HashyObjectValidator < ActiveModel::EachValidator
21
21
  # discard keys that do not have validators
22
22
  value = instance_value.value.stringify_keys.slice(*instance_value.validations.keys)
23
23
 
24
- # we validate each object in the array
25
24
  # if boolean found as any of the validations we force value to boolean - if present
26
25
  instance_value.boolean_attrs.each do |boolean_attr|
27
- value[boolean_attr] = HashyValueValidator.get_boolean_value(t[boolean_attr]) if value.key?(boolean_attr)
28
- end
29
-
30
- # keep track of unique values and add error if needed
31
- instance_value.unique_attrs.each_key do |unique_attr|
32
- if instance_value.unique_attrs[unique_attr].include?(value[unique_attr])
33
- record.errors.add(attribute, "'#{unique_attr}' not unique")
34
- else
35
- instance_value.unique_attrs[unique_attr] << t[unique_attr]
36
- end
26
+ value[boolean_attr] = HashyValueValidator.get_boolean_value(value[boolean_attr]) if value.key?(boolean_attr)
37
27
  end
38
28
 
39
29
  # use default hash validator
@@ -4,7 +4,7 @@ module HashyValidator
4
4
  module Version
5
5
  MAJOR = 0
6
6
  MINOR = 1
7
- PATCH = 5
7
+ PATCH = 6
8
8
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashy_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flecto Team