definition 1.1.0 → 1.1.3

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: e9a9ad734eb7b592f544c631ddb915e97b5aeef740a0d91ba89fba76a09cf630
4
- data.tar.gz: ad91febf1923c32785a43d5c917a15e69eece45cd438f9624e1edd6a06b5d7ab
3
+ metadata.gz: 1d470c4571e1a6f9c4219e749fc16185a5b5064bd663e38505bcad0396f14643
4
+ data.tar.gz: 9f53529e9420d2b4346dfa7edb2d5540ed5771682e86dd9bd55ed143c97b8230
5
5
  SHA512:
6
- metadata.gz: 34d0c1f12d6997a96f5cedf31c90910889f823da1b6b9b5b57a6c21969931799b6effdec2c746aaeb519d34ebccb471c6d7807d872a794f8e896fe10360e3c37
7
- data.tar.gz: 5bbc0b004ca0dfba3f77f4239125ee8f48ea84127228bd594d0aa32255a1876bbfc8e22454c98780aa737136bea84e560cad7ad333390806fe86437b0c37a9a6
6
+ metadata.gz: e35a9cf9a7d0a171f655b6e637b850af4c8b81db15e01761cea554ca9d25150e2fcdcfae90b74e96af9aa771aef5223aa0defc12ce806286976c3bae9b7e9146
7
+ data.tar.gz: 75f9314d97647f14079ae7d476d7f1d7ec1fd9f0ab859adc67b6aca84ac27bdf22ee00f5dfa1d397e8c8548f0e6f95dc69787d9b036103f89a3fc1ea79958cc4
@@ -3,9 +3,9 @@ name: actions
3
3
 
4
4
  on:
5
5
  push:
6
- branches: [ main, master ]
6
+ branches: [main, master]
7
7
  pull_request:
8
- branches: [ main, master ]
8
+ branches: [main, master]
9
9
 
10
10
  permissions:
11
11
  contents: read
@@ -16,7 +16,7 @@ jobs:
16
16
  strategy:
17
17
  fail-fast: false
18
18
  matrix:
19
- ruby-version: ["2.7", "3.0", "3.1", "3.2", "3.3", "jruby-9.3", "jruby-9.4"]
19
+ ruby-version: ["2.7", "3.0", "3.1", "3.2", "3.3", "jruby-9.4"]
20
20
  steps:
21
21
  - uses: actions/checkout@v3
22
22
  - uses: ruby/setup-ruby@v1
@@ -25,4 +25,4 @@ jobs:
25
25
  bundler-cache: false
26
26
  - run: bundle install
27
27
  - run: bundle exec rspec
28
- - run: bundle exec rubocop
28
+ - run: bundle exec rubocop
data/Changelog.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Changelog
2
+
2
3
  All notable changes to this project will be documented in this file.
3
4
 
4
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
@@ -6,87 +7,147 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
7
 
7
8
  ## Unreleased
8
9
 
10
+ ## [1.1.3] - 2025-10-27
11
+
12
+ ### Fixed
13
+
14
+ - Fixed TypeError when using Definition.CoercibleType with certain non coercible values
15
+
16
+ ## [1.1.2] - 2024-08-22
17
+
18
+ ### Fixed
19
+
20
+ - Fixed "TypeError: no \_dump_data is defined for class Proc" error that ocurred when a definition model inherits from another model that uses lambda based definitions
21
+
22
+ ## [1.1.1] - 2024-05-21
23
+
24
+ ### Fixed
25
+
26
+ - Fixed Definition::Model inheritance
27
+
9
28
  ## [1.1.0] - 2023-11-22
29
+
10
30
  ### Changes
31
+
11
32
  - Improved performance
12
33
 
13
34
  ## [1.0.0] - 2023-02-14
35
+
14
36
  ### Removed
37
+
15
38
  - Removed deprecated version of `GreaterThanEqual` definition that had a typo in it (GreaterThenEqual)
16
39
  - Removed deprecated version of `GreaterThan` definition that had a typo in it (GreaterThen)
17
40
  - Removed deprecated version of `LessThanEqual` definition that had a typo in it (LessThenEqual)
18
41
  - Removed deprecated version of `LessThan` definition that had a typo in it (LessThen)
19
42
 
20
43
  ## [0.8.1] - 2022-10-05
44
+
21
45
  ### Fixed
46
+
22
47
  - Definition::Model#eql? returns true when comparing two models with the same content
23
48
 
24
49
  ## [0.8.0] - 2022-10-05
50
+
25
51
  ### Added
52
+
26
53
  - A Definition::Initializer mixin that can be used to validate keyword arguments of a class constructor
27
54
 
28
55
  ### Changes
56
+
29
57
  - Include more information in the internal non-translated error messages. E.g. the max size of a LessThenEqual definition
30
58
  - Renamed GreaterThen, GreaterThenEqual, LessThen and LessThenEqual to fix typo (Then VS Than) Backwards compatibility is ensured
31
59
 
32
60
  ### Breaking changes
61
+
33
62
  - The Definition::ValueObject was removed and replaced by Definition:Model which has a nicer DSL and only works with hash data structures. See [upgrade notes](./UpgradeNotes.md)
34
63
 
35
64
  ## [0.7.1] - 2022-03-04
65
+
36
66
  ### Fixed
67
+
37
68
  - Float coercion: check for nil before coercion
38
69
 
39
70
  ## [0.7.0] - 2022-02-25
71
+
40
72
  ### Added
73
+
41
74
  - Lambda definitions can now be failed with custom error messages
42
75
  - Compatibility with Ruby 3.0
76
+
43
77
  ### Fixed
78
+
44
79
  - In some cases errors from nested `Keys` definitions inside `Or` definitions got lost when listing the validation errors via the `error_hash` method on the conform result object.
80
+
45
81
  ### Changed
82
+
46
83
  - When no sub-definition of an `Or` conforms, then only the errors of the last definition of the `Or` are collected. Previously the errors of all sub-definitions were collected.
47
84
  - Translated error messages have been improved to be more suitable to be used as end user error messages
48
85
 
49
86
  ## [0.6.1] - 2021-12-14
87
+
50
88
  ### Fixed
89
+
51
90
  - The `Keys` definition crashed with an error if the input was not a Hash
52
91
 
53
92
  ## [0.6.0] - 2020-03-21
93
+
54
94
  ### Added
95
+
55
96
  - Added include method to Keys Definition that allows to inline other `Keys` Definitions into each other
56
97
 
57
98
  ## [0.5.2] - 2019-06-03
99
+
58
100
  ### Fixed
101
+
59
102
  - added missing require for "pathname"
60
103
 
61
104
  ## [0.5.1] - 2019-04-27
105
+
62
106
  ### Fixed
107
+
63
108
  - Typo in error debug output
64
109
 
65
110
  ## [0.5.0] - 2019-03-28
111
+
66
112
  ### Added
113
+
67
114
  - CoercibleValueObject Definition for better nesting of ValueObjects
68
115
  - Nilable Definition as shortcut for nil OR some other definition
69
116
  - Option for Keys Definition to ignore unexpected keys
117
+
70
118
  ### Fixed
119
+
71
120
  - Error hash was missing some errors in a few cases
72
121
  - `ConformResult.error_hash` was empty for Definitions without any `Keys` Definition
122
+
73
123
  ### Changed
124
+
74
125
  - And Definition stops processing after the first failure
75
126
 
76
127
  ## [0.4.0] - 2019-03-22
128
+
77
129
  ### Added
130
+
78
131
  - Added support for default values to Keys Definition
132
+
79
133
  ### Changed
134
+
80
135
  - Errors returned from ConformResult were restructured for better debugging and usage
81
136
 
82
137
  ## [0.3.0] - 2019-02-03
138
+
83
139
  ### Added
140
+
84
141
  - Added I18n translation support for errors
85
142
 
86
143
  ## [0.2.0] - 2019-01-13
144
+
87
145
  ### Added
146
+
88
147
  - Added built in definitions for common usecases (e.g. string length validation)
89
148
 
90
149
  ## [0.1.0] - 2019-01-12
150
+
91
151
  ### Added
152
+
92
153
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- definition (1.1.0)
4
+ definition (1.1.3)
5
5
  activesupport
6
6
  i18n
7
7
 
@@ -64,9 +64,9 @@ GEM
64
64
  minitest (5.21.2)
65
65
  mutex_m (0.2.0)
66
66
  nenv (0.3.0)
67
- nokogiri (1.16.0-arm64-darwin)
67
+ nokogiri (1.18.4-arm64-darwin)
68
68
  racc (~> 1.4)
69
- nokogiri (1.16.0-x86_64-linux)
69
+ nokogiri (1.18.4-x86_64-linux-gnu)
70
70
  racc (~> 1.4)
71
71
  notiffany (0.1.3)
72
72
  nenv (~> 0.1)
@@ -80,7 +80,7 @@ GEM
80
80
  method_source (~> 1.0)
81
81
  psych (5.1.2)
82
82
  stringio
83
- racc (1.7.3)
83
+ racc (1.8.1)
84
84
  rainbow (3.1.1)
85
85
  rake (13.1.0)
86
86
  rb-fsevent (0.11.2)
@@ -42,7 +42,7 @@ module Definition
42
42
  end
43
43
  Types::Type.new(:type, klass) do |value|
44
44
  method(klass.name).call(value)
45
- rescue ArgumentError
45
+ rescue ArgumentError, TypeError
46
46
  value
47
47
  end
48
48
  end
@@ -37,7 +37,11 @@ module Definition
37
37
  end
38
38
 
39
39
  def _definition
40
- @_definition ||= ::Definition.Keys {}
40
+ @_definition ||= if superclass == ::Definition::Model
41
+ ::Definition.Keys {}
42
+ else
43
+ superclass._definition.dup
44
+ end
41
45
  end
42
46
  end
43
47
 
@@ -63,6 +63,13 @@ module Definition
63
63
  self.ignore_extra_keys = options.fetch(:ignore_extra_keys, false)
64
64
  end
65
65
 
66
+ def initialize_dup(_other)
67
+ super
68
+ self.required_definitions = required_definitions.dup
69
+ self.optional_definitions = optional_definitions.dup
70
+ self.defaults = defaults.dup
71
+ end
72
+
66
73
  def conform(input_value) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
67
74
  # input_value is duplicated because we don't want to modify the user object that is passed into this function.
68
75
  # The following logic will iterate over each definition and delete the key associated with the definition from
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Definition
4
- VERSION = "1.1.0"
4
+ VERSION = "1.1.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: definition
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Goltermann
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-01-22 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -248,7 +247,6 @@ dependencies:
248
247
  - - ">="
249
248
  - !ruby/object:Gem::Version
250
249
  version: '0'
251
- description:
252
250
  email:
253
251
  - dominik@goltermann.cc
254
252
  executables: []
@@ -306,7 +304,6 @@ homepage: https://github.com/Goltergaul/definition
306
304
  licenses:
307
305
  - MIT
308
306
  metadata: {}
309
- post_install_message:
310
307
  rdoc_options: []
311
308
  require_paths:
312
309
  - lib
@@ -321,8 +318,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
321
318
  - !ruby/object:Gem::Version
322
319
  version: '0'
323
320
  requirements: []
324
- rubygems_version: 3.5.3
325
- signing_key:
321
+ rubygems_version: 3.6.9
326
322
  specification_version: 4
327
323
  summary: Simple and composable validation and coercion of data structures inspired
328
324
  by clojure specs