activerecord_json_validator 2.1.5 → 3.0.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: 46e15a1f3a280bc1f2a5d197d0631a6b0e09a4beed596e971d66e1102e3a9c65
4
- data.tar.gz: dfc7b7fd68462c50be8fb565d20d965fad13a29d487013df54d5cfab708b431d
3
+ metadata.gz: 669da2ce3ee468c5d588289edf6842fbec2e90a04058b110db4fc81fe10cb0e7
4
+ data.tar.gz: 76b04ff20e88c285ffd5711dc1ce6bee16c7e9bdf519a3ef95dac637d7a4b147
5
5
  SHA512:
6
- metadata.gz: a6b1c7770312b89c64889d8a1abeb6b59603b1be24a431e1a68cb9800268fbe36e617a1812d85c3f508ff603ffb1672c8c13a7c136847dd5b18959d815ef3304
7
- data.tar.gz: 7aaf73c426c7918abb1323cc5812c04d5d8a3700192d7a0222dee9c23f2faa638692764926d34947a752ac6cb8cb14223c414f34a2595a101839ccbb11bb2552
6
+ metadata.gz: 40ccc0aa96e3601e49a6cb38fa35b83158f5b9a4597916577416b316f144534d271c56b17b42b5fe7071cdffd8f87c2b1ac3d84bfaa0da5794372eff6c5b9d89
7
+ data.tar.gz: 8a79553fc7bb7ab146ab77ed0ac57e186b7f9fd0f6cb6f47dd5e7bd94b920796abafd8d3d09e99a3954cf520f4aab6bb208341cd06aa29bb68ba0175763e949d
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013-2022, Mirego
1
+ Copyright (c) 2013-2024, Mirego
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
data/README.md CHANGED
@@ -16,7 +16,7 @@
16
16
  Add this line to your application's Gemfile:
17
17
 
18
18
  ```ruby
19
- gem 'activerecord_json_validator', '~> 2.1.0'
19
+ gem 'activerecord_json_validator', '~> 3.0.0'
20
20
  ```
21
21
 
22
22
  ## Usage
@@ -175,7 +175,7 @@ appropriately.
175
175
 
176
176
  ## License
177
177
 
178
- `ActiveRecord::JSONValidator` is © 2013-2022 [Mirego](https://www.mirego.com) and may be freely distributed under the [New BSD license](https://opensource.org/licenses/BSD-3-Clause). See the [`LICENSE.md`](https://github.com/mirego/activerecord_json_validator/blob/master/LICENSE.md) file.
178
+ `ActiveRecord::JSONValidator` is © 2013-2024 [Mirego](https://www.mirego.com) and may be freely distributed under the [New BSD license](https://opensource.org/licenses/BSD-3-Clause). See the [`LICENSE.md`](https://github.com/mirego/activerecord_json_validator/blob/master/LICENSE.md) file.
179
179
 
180
180
  The tree logo is based on [this lovely icon](https://thenounproject.com/term/tree/51004/) by [Sara Quintana](https://thenounproject.com/sara.quintana.75), from The Noun Project. Used under a [Creative Commons BY 3.0](https://creativecommons.org/licenses/by/3.0/) license.
181
181
 
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'rubocop-rspec', '~> 1.44'
28
28
  spec.add_development_dependency 'rubocop-standard', '~> 6.0'
29
29
 
30
- spec.add_dependency 'json_schemer', '~> 0.2.18'
30
+ spec.add_dependency 'json_schemer', '~> 2.2'
31
31
  spec.add_dependency 'activerecord', '>= 4.2.0', '< 8'
32
32
  end
@@ -25,9 +25,9 @@ class JsonValidator < ActiveModel::EachValidator
25
25
  return if errors.empty? && record.send(:"#{attribute}_invalid_json").blank?
26
26
 
27
27
  # Add error message to the attribute
28
- details = errors.map { |e| JSONSchemer::Errors.pretty(e) }
28
+ details = errors.map { |e| e.fetch('error') }
29
29
  message(errors).each do |error|
30
- error = JSONSchemer::Errors.pretty(error) if error.is_a?(Hash)
30
+ error = error.fetch('error') if error.is_a?(Hash)
31
31
  record.errors.add(attribute, error, errors: details, value: value)
32
32
  end
33
33
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  module JSONValidator
5
- VERSION = '2.1.5'
5
+ VERSION = '3.0.0'
6
6
  end
7
7
  end
@@ -41,8 +41,8 @@ describe JsonValidator do
41
41
 
42
42
  default_country_attribute :smart_data, country: 'Canada'
43
43
 
44
- serialize :data, JSON
45
- serialize :other_data, JSON
44
+ serialize :data, coder: JSON
45
+ serialize :other_data, coder: JSON
46
46
  validates :data, json: { schema: schema, message: ->(errors) { errors } }
47
47
  validates :other_data, json: { schema: schema, message: ->(errors) { errors.map { |error| error['details'].to_a.flatten.join(' ') } } }
48
48
  validates :smart_data, json: { value: ->(record, _, _) { record[:smart_data] }, schema: schema, message: ->(errors) { errors } }
@@ -64,12 +64,12 @@ describe JsonValidator do
64
64
 
65
65
  specify do
66
66
  expect(user).not_to be_valid
67
- expect(user.errors.full_messages).to eql(['Data root is missing required keys: country', 'Other data missing_keys country'])
67
+ expect(user.errors.full_messages).to eql(['Data object at root is missing required properties: country', 'Other data missing_keys country'])
68
68
  expect(user.errors.group_by_attribute[:data].first).to have_attributes(
69
- options: include(errors: ['root is missing required keys: country'])
69
+ options: include(errors: ['object at root is missing required properties: country'])
70
70
  )
71
71
  expect(user.errors.group_by_attribute[:other_data].first).to have_attributes(
72
- options: include(errors: ['root is missing required keys: country'])
72
+ options: include(errors: ['object at root is missing required properties: country'])
73
73
  )
74
74
  expect(user.data).to eql({ 'city' => 'Quebec City' })
75
75
  expect(user.data_invalid_json).to be_nil
@@ -25,6 +25,6 @@ module DatabaseMacros
25
25
  adapter.reset_database!
26
26
 
27
27
  # Silence everything
28
- ActiveRecord::Base.logger = ActiveRecord::Migration.verbose = false
28
+ ActiveRecord::Base.logger = ActiveRecord::Migration.verbose = nil
29
29
  end
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_json_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rémi Prévost
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-23 00:00:00.000000000 Z
11
+ date: 2024-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -134,14 +134,14 @@ dependencies:
134
134
  requirements:
135
135
  - - "~>"
136
136
  - !ruby/object:Gem::Version
137
- version: 0.2.18
137
+ version: '2.2'
138
138
  type: :runtime
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
142
  - - "~>"
143
143
  - !ruby/object:Gem::Version
144
- version: 0.2.18
144
+ version: '2.2'
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: activerecord
147
147
  requirement: !ruby/object:Gem::Requirement