hashy_validator 0.1.5 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 65bbe593f0a313de084f7bd4a7ab23075422a068a7bea5dc6903f55a7243b09e
4
- data.tar.gz: b86b243a6e39958a38b8c51bd1d2ce2644e0581a6929956faf74d8c83cab2a34
3
+ metadata.gz: 3cb3632476f5a316a64e1c637dfac400320b4594a2ea83c07024eebe0b74c075
4
+ data.tar.gz: 175b7d7073462ae92d85f1701cc0addaba2f20d99f2208c401628812485ad83c
5
5
  SHA512:
6
- metadata.gz: af7fd7055e2bf2462ae5784668f7c42d502abfd293e72c4ded6d17d5694182b92342ffb3f22a45063534d81ad53b15c0652092e66490abe46a8428a8acfba166
7
- data.tar.gz: 74a8d08f9409cd379a2be4af5a82118323ed36dbfb097cddac2fc9b8860348efb37d401c18da6040dbd04bc70adde05483dd72d600fc716d1c58af1d5c7fbd2b
6
+ metadata.gz: ccbbd9b3e52bd231c04c5d0a1666d6ed6cf2de4f81865617a74aa5548274f98ee863556c910b4f04687efc2aa9725a57ef5d9787c64bb2755c0ecfade8fe3840
7
+ data.tar.gz: df0f70b55657431c6cbbc69c1f974c55feeb8c99c6dcf6f75d1980f9b8116f584a707744af7fe4da32149c4f340f57fc9c41b3a5d6733f45e1a6aba37ee3661f
data/CHANGELOG.md CHANGED
@@ -5,6 +5,20 @@ 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.2.0](https://www.github.com/flecto-io/hashy-validator/compare/v0.1.6...v0.2.0) (2025-01-29)
9
+
10
+
11
+ ### Features
12
+
13
+ * prepare for Rails 8 ( activerecord dependency ) ([#31](https://www.github.com/flecto-io/hashy-validator/issues/31)) ([9443cf2](https://www.github.com/flecto-io/hashy-validator/commit/9443cf27b95c16cfa65b8028a2cf59bb891df8e4))
14
+
15
+ ### [0.1.6](https://www.github.com/flecto-io/hashy-validator/compare/v0.1.5...v0.1.6) (2024-09-05)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * handle nil object and boolean cases ([74deb27](https://www.github.com/flecto-io/hashy-validator/commit/74deb276c08c4ebb85954cb6d1fe098308f914a6))
21
+
8
22
  ### [0.1.5](https://www.github.com/flecto-io/hashy-validator/compare/v0.1.4...v0.1.5) (2024-09-05)
9
23
 
10
24
 
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.require_paths = ["lib"]
15
15
  spec.files = Dir["{lib}/**/*"] + ["README.md", "CHANGELOG.md", "hashy_validator.gemspec"]
16
16
 
17
- spec.add_dependency "activerecord", ">= 6.0.0", "< 8.0.0"
17
+ spec.add_dependency "activerecord"
18
18
  spec.add_dependency "hash_validator", "~> 1.1"
19
19
 
20
20
  spec.add_development_dependency 'sqlite3', '~> 1.4'
@@ -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
@@ -3,8 +3,8 @@
3
3
  module HashyValidator
4
4
  module Version
5
5
  MAJOR = 0
6
- MINOR = 1
7
- PATCH = 5
6
+ MINOR = 2
7
+ PATCH = 0
8
8
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,11 +1,11 @@
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.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flecto Team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2013-12-31 00:00:00.000000000 Z
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 6.0.0
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: 8.0.0
19
+ version: '0'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 6.0.0
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: 8.0.0
26
+ version: '0'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: hash_validator
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -159,10 +153,10 @@ files:
159
153
  - lib/hashy_validator/hashy_object_validator.rb
160
154
  - lib/hashy_validator/hashy_value_validator.rb
161
155
  - lib/hashy_validator/version.rb
162
- homepage:
156
+ homepage:
163
157
  licenses: []
164
158
  metadata: {}
165
- post_install_message:
159
+ post_install_message:
166
160
  rdoc_options: []
167
161
  require_paths:
168
162
  - lib
@@ -178,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
172
  version: '0'
179
173
  requirements: []
180
174
  rubygems_version: 3.4.19
181
- signing_key:
175
+ signing_key:
182
176
  specification_version: 4
183
177
  summary: Custom Active Model validator for validating arrays of hashes
184
178
  test_files: []