json_errors 0.3.0 → 0.3.2
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/.github/workflows/main.yml +2 -2
- data/.gitignore +1 -0
- data/.rubocop.yml +29 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +2 -2
- data/json_errors.gemspec +1 -1
- data/lib/json_errors/config.rb +1 -1
- data/lib/json_errors/error/validation_error.rb +8 -4
- data/lib/json_errors/error.rb +1 -2
- data/lib/json_errors/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b9a7639921c8e484c4b0800c687081c65d216917e0ebdab96c957266e5070be
|
4
|
+
data.tar.gz: c912067d04d9774d380363d35267b7cf9a4391e4ab26b99dabd66b9636a0071f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f438484bb012fd9f0f5bb97cb9774f0046c06e3d1c843be2b13b4730abba0b15eaebb88d763efb2b69ef2336d233fd44c66927c6904f4d64bf869c50499fb40
|
7
|
+
data.tar.gz: 3b13227880fd38e8399cd0abb320c59f69f67559230ed55319e771ad25320fb58f6e6f573da230addbd6ffd2db90f947437d86246891bc420c8d2d0e76f5428c
|
data/.github/workflows/main.yml
CHANGED
@@ -10,10 +10,10 @@ jobs:
|
|
10
10
|
- name: Set up Ruby
|
11
11
|
uses: ruby/setup-ruby@v1
|
12
12
|
with:
|
13
|
-
ruby-version: 3.
|
13
|
+
ruby-version: 3.4.1
|
14
14
|
- name: Run the default task
|
15
15
|
run: |
|
16
|
-
gem install bundler -v 2.
|
16
|
+
gem install bundler -v 2.6.5
|
17
17
|
bundle install
|
18
18
|
bundle exec rake rubocop
|
19
19
|
bundle exec rake
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
+
plugins:
|
2
|
+
- rubocop-rake
|
3
|
+
- rubocop-rspec
|
4
|
+
|
1
5
|
AllCops:
|
2
6
|
TargetRubyVersion: 3.0
|
3
7
|
NewCops: enable
|
8
|
+
SuggestExtensions: false
|
4
9
|
|
5
10
|
Layout/LineLength:
|
6
11
|
Max: 120
|
@@ -10,3 +15,27 @@ Metrics/BlockLength:
|
|
10
15
|
Exclude:
|
11
16
|
- spec/**/*
|
12
17
|
- config/**/*
|
18
|
+
|
19
|
+
RSpec/SpecFilePathFormat:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
RSpec/VerifiedDoubles:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
RSpec/NestedGroups:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
RSpec/MultipleExpectations:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
RSpec/SubjectStub:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
RSpec/MessageSpies:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
RSpec/DescribedClass:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
RSpec/VerifiedDoubleReference:
|
41
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.3.2] - 2025-02-27
|
4
|
+
|
5
|
+
- bugfix: Active record validation errors were never shown
|
6
|
+
|
7
|
+
## [0.3.1] - 2025-02-27
|
8
|
+
|
9
|
+
- bugfix: Wrong ActiveRecord error format
|
10
|
+
|
11
|
+
## [0.3.0] - 2025-02-27
|
12
|
+
|
13
|
+
- Update with ActiveRecord validation errors to Rails 8
|
14
|
+
|
3
15
|
## [0.2.1] - 2021-08-03
|
4
16
|
|
5
17
|
- Error log formatting fixed
|
data/Gemfile.lock
CHANGED
data/json_errors.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ['lib']
|
29
29
|
|
30
|
-
spec.add_dependency 'activesupport',
|
30
|
+
spec.add_dependency 'activesupport', '~> 8.0'
|
31
31
|
|
32
32
|
# For more information and examples about making a new gem, checkout our
|
33
33
|
# guide at: https://bundler.io/guides/creating_gem.html
|
data/lib/json_errors/config.rb
CHANGED
@@ -10,7 +10,7 @@ module JsonErrors
|
|
10
10
|
attr_accessor :error_dictionary, :custom_codes
|
11
11
|
|
12
12
|
def self.missing_config_error_meesage
|
13
|
-
<<~
|
13
|
+
<<~MSG
|
14
14
|
Configuration is missing. Run the generattor: `bundle exec rails g json_errors::install`
|
15
15
|
or create the initializer yourself.
|
16
16
|
Check out the README https://github.com/nomtek/JsonErrors/blob/main/README.md
|
@@ -23,12 +23,16 @@ module JsonErrors
|
|
23
23
|
attr_reader :record
|
24
24
|
|
25
25
|
def payload
|
26
|
-
validation_payload =
|
27
|
-
|
28
|
-
|
26
|
+
validation_payload = record.errors.map do |error|
|
27
|
+
{
|
28
|
+
'object' => record.class.to_s,
|
29
|
+
'attribute' => error.attribute,
|
30
|
+
'error_type' => error.type,
|
31
|
+
'message' => error.full_message
|
32
|
+
}
|
29
33
|
end
|
30
34
|
|
31
|
-
{
|
35
|
+
{ 'validation_errors' => validation_payload }
|
32
36
|
end
|
33
37
|
end
|
34
38
|
end
|
data/lib/json_errors/error.rb
CHANGED
@@ -6,9 +6,8 @@ module JsonErrors
|
|
6
6
|
def self.method_missing(name, *args)
|
7
7
|
message, payload = args
|
8
8
|
return super unless name.in?(codes.keys)
|
9
|
-
|
10
|
-
return BasicError.new(message, name) if payload.nil?
|
11
9
|
return ValidationError.new(message, name, payload&.record) if codes[name][:validation_errors] == :active_record
|
10
|
+
return BasicError.new(message, name) if payload.nil?
|
12
11
|
|
13
12
|
CustomPayloadError.new(message, name, payload)
|
14
13
|
end
|
data/lib/json_errors/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_errors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Łukasz Pająk
|
8
8
|
- Nomtek
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|