hashy_validator 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/hashy_validator/hashy_object_validator.rb +2 -12
- data/lib/hashy_validator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68ad620a19feee19aa4ddb694d131b65bd730e36d1241c68c01a56685921a7df
|
4
|
+
data.tar.gz: f58c1ae578d2792fc6951a183a411a027e8f79c56c73d91d7ff44ca0e449451f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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(
|
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
|