dry-types 0.12.3 → 0.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -6
- data/CHANGELOG.md +249 -105
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +0 -2
- data/README.md +0 -2
- data/Rakefile +4 -2
- data/benchmarks/hash_schemas.rb +2 -2
- data/dry-types.gemspec +8 -6
- data/lib/dry/types/array/member.rb +6 -2
- data/lib/dry/types/array.rb +1 -3
- data/lib/dry/types/builder.rb +9 -2
- data/lib/dry/types/builder_methods.rb +22 -1
- data/lib/dry/types/coercions/{form.rb → params.rb} +1 -1
- data/lib/dry/types/compat/form_types.rb +27 -0
- data/lib/dry/types/compat/int.rb +14 -0
- data/lib/dry/types/compat.rb +2 -0
- data/lib/dry/types/compiler.rb +30 -7
- data/lib/dry/types/constructor.rb +13 -5
- data/lib/dry/types/core.rb +4 -3
- data/lib/dry/types/decorator.rb +11 -1
- data/lib/dry/types/default.rb +14 -3
- data/lib/dry/types/definition.rb +3 -13
- data/lib/dry/types/enum.rb +42 -14
- data/lib/dry/types/errors.rb +6 -2
- data/lib/dry/types/extensions/maybe.rb +18 -28
- data/lib/dry/types/fn_container.rb +9 -8
- data/lib/dry/types/hash/schema.rb +99 -180
- data/lib/dry/types/hash/schema_builder.rb +75 -0
- data/lib/dry/types/hash.rb +83 -28
- data/lib/dry/types/inflector.rb +7 -0
- data/lib/dry/types/map.rb +93 -0
- data/lib/dry/types/options.rb +3 -3
- data/lib/dry/types/params.rb +53 -0
- data/lib/dry/types/safe.rb +3 -2
- data/lib/dry/types/spec/types.rb +10 -0
- data/lib/dry/types/sum.rb +12 -6
- data/lib/dry/types/version.rb +1 -1
- data/lib/dry/types.rb +12 -18
- metadata +44 -50
- data/lib/dry/types/form.rb +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56b7935633ed4d23fa17d30082254f98e3e7f642a482c17bdb6f77629f88a399
|
4
|
+
data.tar.gz: f9860f5500c746b10dcdd0aec29c70737d31615dc2342ee2ad7bc1f3e12c9250
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 363ff8a7854062a51c71ff646d5e6c3c9ae1c964be5b99267c77b4cbfc5efa9d99b0466cdc736d142859aa624be99bb9fba1cf89bf9282eeb71f234eb5e3898f
|
7
|
+
data.tar.gz: 6f6b1714103ea16df7a837c9e0a5b9488adf59f6eddeb8f28228c09daeb843edabacdae54ce9d4b461010c4851f75f8da5860f210b943b1a879105dd85dfd2bf
|
data/.travis.yml
CHANGED
@@ -3,15 +3,16 @@ dist: trusty
|
|
3
3
|
sudo: required
|
4
4
|
cache: bundler
|
5
5
|
bundler_args: --without benchmarks tools
|
6
|
-
after_success:
|
7
|
-
- '[ -d coverage ] && bundle exec codeclimate-test-reporter'
|
8
6
|
script:
|
9
7
|
- bundle exec rake
|
8
|
+
after_success:
|
9
|
+
- '[ -d coverage ] && bundle exec codeclimate-test-reporter'
|
10
10
|
rvm:
|
11
|
-
- 2.
|
12
|
-
- 2.
|
13
|
-
- 2.
|
14
|
-
-
|
11
|
+
- 2.3.8
|
12
|
+
- 2.4.5
|
13
|
+
- 2.5.5
|
14
|
+
- 2.6.2
|
15
|
+
- jruby-9.2.6.0
|
15
16
|
env:
|
16
17
|
global:
|
17
18
|
- COVERAGE=true
|
data/CHANGELOG.md
CHANGED
@@ -1,19 +1,163 @@
|
|
1
|
-
# v0.
|
1
|
+
# v0.14.1 2019-03-25
|
2
2
|
|
3
3
|
## Fixed
|
4
|
+
- `coercible.integer` now doesn't blow up on invalid strings (exterm)
|
4
5
|
|
5
|
-
|
6
|
+
[Compare v0.14.0...v0.14.1](https://github.com/dry-rb/dry-types/compare/v0.14.0...v0.14.1)
|
6
7
|
|
7
|
-
|
8
|
+
# v0.14.0 2019-01-29
|
9
|
+
|
10
|
+
## Changed
|
11
|
+
|
12
|
+
- [BREAKING] Support for Ruby 2.2 was dropped. It reached EOL on March 31, 2018.
|
13
|
+
- `dry-logic` was updated to `~> 0.5` (solnic)
|
14
|
+
|
15
|
+
## Fixed
|
16
|
+
|
17
|
+
- `valid?` works correctly with constructors now (cgeorgii)
|
18
|
+
|
19
|
+
[Compare v0.13.4...v0.14.0](https://github.com/dry-rb/dry-types/compare/v0.13.4...v0.14.0)
|
20
|
+
|
21
|
+
# v0.13.4 2018-12-21
|
22
|
+
|
23
|
+
## Fixed
|
24
|
+
|
25
|
+
- Fixed warnings about keyword arguments from Ruby 2.6. See https://bugs.ruby-lang.org/issues/14183 for all the details (flash-gordon)
|
26
|
+
|
27
|
+
# v0.13.3 2018-11-25
|
28
|
+
|
29
|
+
## Fixed
|
30
|
+
|
31
|
+
- `Dry::Types::Hash#try` returns `Failure` instead of throwing an exception on missing keys (GustavoCaso)
|
32
|
+
|
33
|
+
[Compare v0.13.2...v0.13.3](https://github.com/dry-rb/dry-types/compare/v0.13.2...v0.13.3)
|
34
|
+
|
35
|
+
# v0.13.2 2018-05-30
|
36
|
+
|
37
|
+
## Fixed
|
38
|
+
|
39
|
+
- `Defaults#valid?` now works fine when passing `Dry::Core::Constans::Undefined` as value (GustavoCaso)
|
40
|
+
- `valid?` for constructor types wrapping `Sum`s (GustavoCaso)
|
41
|
+
|
42
|
+
[Compare v0.13.1...v0.13.2](https://github.com/dry-rb/dry-types/compare/v0.13.1...v0.13.2)
|
43
|
+
|
44
|
+
# v0.13.1 2018-05-28
|
45
|
+
|
46
|
+
## Fixed
|
47
|
+
|
48
|
+
- Defaults now works fine with meta (GustavoCaso)
|
49
|
+
- Defaults are now re-decorated properly (flash-gordon)
|
50
|
+
|
51
|
+
## Added
|
52
|
+
|
53
|
+
- `params.int` was added to make the upgrade process in dry-validation smoother (available after you `require 'dry/types/compat/int'`) (flash-gordon)
|
54
|
+
|
55
|
+
[Compare v0.13.0...v0.13.1](https://github.com/dry-rb/dry-types/compare/v0.13.0...v0.13.1)
|
56
|
+
|
57
|
+
# v0.13.0 2018-05-03
|
58
|
+
|
59
|
+
## Changed
|
60
|
+
|
61
|
+
- [BREAKING] Renamed `Types::Form` to `Types::Params`. You can opt-in the former name with `require 'dry/types/compat/form_types'`. It will be dropped in the next release (ndrluis)
|
62
|
+
- [BREAKING] The `Int` types was renamed to `Integer`, this was the only type named differently from the standard Ruby classes so it has been made consistent. The former name is available with `require 'dry/types/compat/int'` (GustavoCaso + flash-gordon)
|
63
|
+
- [BREAKING] Default types are not evaluated on `nil`. Default values are evaluated _only_ if no value were given.
|
64
|
+
```ruby
|
65
|
+
type = Types::Strict::String.default("hello")
|
66
|
+
type[nil] # => constraint error
|
67
|
+
type[] # => "hello"
|
68
|
+
```
|
69
|
+
This change allowed to greatly simplify hash schemas, make them a lot more flexible yet predictable (see below).
|
70
|
+
- [BREAKING] `Dry::Types.register_class` was removed, `Dry::Types.register` was made private API, do not register your types in the global `dry-types` container, use a module instead, e.g. `Types` (flash-gordon)
|
71
|
+
- [BREAKING] Enum types don't accept value index anymore. Instead, explicit mapping is supported, see below (flash-gordon)
|
72
|
+
|
73
|
+
## Added
|
74
|
+
|
75
|
+
- Hash schemas were rewritten. The old API is still around but is going to be deprecated and removed before 1.0. The new API is simpler and more flexible. Instead of having a bunch of predefined schemas you can build your own by combining the following methods:
|
76
|
+
|
77
|
+
1. `Schema#with_key_transform`—transforms keys of input hashes, for things like symbolizing etc.
|
78
|
+
2. `Schema#strict`—makes a schema intolerant to unknown keys.
|
79
|
+
3. `Hash#with_type_transform`—transforms member types with an arbitrary block. For instance,
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
optional_keys = Types::Hash.with_type_transform { |t, _key| t.optional }
|
83
|
+
schema = optional_keys.schema(name: 'strict.string', age: 'strict.int')
|
84
|
+
schema.(name: "Jane", age: nil) # => {name: "Jane", age: nil}
|
85
|
+
```
|
86
|
+
|
87
|
+
Note that by default all keys are required, if a key is expected to be absent, add to the corresponding type's meta `omittable: true`:
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
intolerant = Types::Hash.schema(name: Types::Strict::String)
|
91
|
+
intolerant[{}] # => Dry::Types::MissingKeyError
|
92
|
+
tolerant = Types::Hash.schema(name: Types::Strict::String.meta(omittable: true))
|
93
|
+
tolerant[{}] # => {}
|
94
|
+
tolerant_with_default = Types::Hash.schema(name: Types::Strict::String.meta(omittable: true).default("John"))
|
95
|
+
tolerant[{}] # => {name: "John"}
|
96
|
+
```
|
97
|
+
|
98
|
+
The new API is composable in a natural way:
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
TOLERANT = Types::Hash.with_type_transform { |t| t.meta(omittable: true) }.freeze
|
102
|
+
user = TOLERANT.schema(name: 'strict.string', age: 'strict.int')
|
103
|
+
user.(name: "Jane") # => {name: "Jane"}
|
104
|
+
|
105
|
+
TOLERANT_SYMBOLIZED = TOLERANT.with_key_transform(&:to_sym)
|
106
|
+
user_sym = TOLERANT_SYMBOLIZED.schema(name: 'strict.string', age: 'strict.int')
|
107
|
+
user_sym.("name" => "Jane") # => {name: "Jane"}
|
108
|
+
```
|
109
|
+
|
110
|
+
(flash-gordon)
|
111
|
+
|
112
|
+
- `Types.Strict` is an alias for `Types.Instance` (flash-gordon)
|
113
|
+
```ruby
|
114
|
+
strict_range = Types.Strict(Range)
|
115
|
+
strict_range == Types.Instance(Range) # => true
|
116
|
+
```
|
117
|
+
- `Enum#include?` is an alias to `Enum#valid?` (d-Pixie + flash-gordon)
|
118
|
+
- `Range` was added (GustavoCaso)
|
119
|
+
- `Array` types filter out `Undefined` values, if you have an array type with a constructor type as its member, the constructor now can return `Dry::Types::Undefined` to indicate empty value:
|
120
|
+
```ruby
|
121
|
+
filter_empty_strings = Types::Strict::Array.of(
|
122
|
+
Types::Strict::String.constructor { |input|
|
123
|
+
input.to_s.yield_self { |s| s.empty? ? Dry::Types::Undefined : s }
|
124
|
+
}
|
125
|
+
)
|
126
|
+
filter_empty_strings.(["John", nil, "", "Jane"]) # => ["John", "Jane"]
|
127
|
+
```
|
128
|
+
- `Types::Map` was added for homogeneous hashes, when only types of keys and values are known in advance, not specific key names (fledman + flash-gordon)
|
129
|
+
```ruby
|
130
|
+
int_to_string = Types::Hash.map('strict.integer', 'strict.string')
|
131
|
+
int_to_string[0 => 'foo'] # => { 0 => "foo" }
|
132
|
+
int_to_string[0 => 1] # Dry::Types::MapError: input value 1 for key 0 is invalid: type?(String, 1)
|
133
|
+
```
|
134
|
+
- Enum supports mappings (bolshakov + flash-gordon)
|
135
|
+
```ruby
|
136
|
+
dict = Types::Strict::String.enum('draft' => 0, 'published' => 10, 'archived' => 20)
|
137
|
+
dict['published'] # => 'published'
|
138
|
+
dict[10] # => 'published'
|
139
|
+
```
|
140
|
+
|
141
|
+
## Fixed
|
142
|
+
|
143
|
+
- Fixed applying constraints to optional type, i.e. `.optional.constrained` works correctly (flash-gordon)
|
144
|
+
- Fixed enum working with optionals (flash-gordon)
|
145
|
+
|
146
|
+
## Internal
|
147
|
+
|
148
|
+
- Dropped the `dry-configurable` dependency (GustavoCaso)
|
149
|
+
- The gem now uses `dry-inflector` for inflections instead of `inflecto` (GustavoCaso)
|
150
|
+
|
151
|
+
[Compare v0.12.2...v0.13.0](https://github.com/dry-rb/dry-types/compare/v0.12.2...v0.13.0)
|
8
152
|
|
9
153
|
# v0.12.2 2017-11-04
|
10
154
|
|
11
155
|
## Fixed
|
12
156
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
157
|
+
- The type compiler was fixed for simple rules such as used for strict type checks (flash-gordon)
|
158
|
+
- Fixed an error on `Dry::Types['json.decimal'].try(nil)` (nesaulov)
|
159
|
+
- Fixed an error on calling `try` on an array type built of constrained types (flash-gordon)
|
160
|
+
- Implemented `===` for enum types (GustavoCaso)
|
17
161
|
|
18
162
|
[Compare v0.12.1...v0.12.2](https://github.com/dry-rb/dry-types/compare/v0.12.1...v0.12.2)
|
19
163
|
|
@@ -21,10 +165,10 @@
|
|
21
165
|
|
22
166
|
## Fixed
|
23
167
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
168
|
+
- `Constructor#try` rescues `ArgumentError` (raised in cases like `Integer('foo')`) (flash-gordon)
|
169
|
+
- `#constructor` works correctly for default and enum types (solnic)
|
170
|
+
- Optional sum types work correctly in `safe` mode (GustavoCaso)
|
171
|
+
- The equalizer of constrained types respects meta (flash-gordon)
|
28
172
|
|
29
173
|
[Compare v0.12.0...v0.12.1](https://github.com/dry-rb/dry-types/compare/v0.12.0...v0.12.1)
|
30
174
|
|
@@ -32,11 +176,11 @@
|
|
32
176
|
|
33
177
|
## Added
|
34
178
|
|
35
|
-
|
179
|
+
- A bunch of shortcut methods for constructing types to the autogenerated module, e.g. `Types.Constructor(String, &:to_s)` (flash-gordon)
|
36
180
|
|
37
181
|
## Deprecated
|
38
182
|
|
39
|
-
|
183
|
+
- `Types::Array#member` was deprecated in favor of `Types::Array#of` (flash-gordon)
|
40
184
|
|
41
185
|
[Compare v0.11.1...v0.12.0](https://github.com/dry-rb/dry-types/compare/v0.11.1...v0.12.0)
|
42
186
|
|
@@ -44,11 +188,11 @@
|
|
44
188
|
|
45
189
|
## Changed
|
46
190
|
|
47
|
-
|
191
|
+
- Constructors are now equalized using `fn` and `meta` too (flash-gordon)
|
48
192
|
|
49
193
|
## Fixed
|
50
194
|
|
51
|
-
|
195
|
+
- Fixed `Constructor#name` with `Sum`-types (flash-gordon)
|
52
196
|
|
53
197
|
[Compare v0.11.0...v0.11.1](https://github.com/dry-rb/dry-types/compare/v0.11.0...v0.11.1)
|
54
198
|
|
@@ -56,9 +200,9 @@
|
|
56
200
|
|
57
201
|
## Added
|
58
202
|
|
59
|
-
|
60
|
-
|
61
|
-
|
203
|
+
- `#to_ast` available for all type objects (GustavoCaso)
|
204
|
+
- `Types::Array#of` as an alias for `#member` (maliqq)
|
205
|
+
- Detailed failure objects are passed to results which improves constraint violation messages (GustavoCaso)
|
62
206
|
|
63
207
|
[Compare v0.10.3...v0.11.0](https://github.com/dry-rb/dry-types/compare/v0.10.3...v0.11.0)
|
64
208
|
|
@@ -66,7 +210,7 @@
|
|
66
210
|
|
67
211
|
## Added
|
68
212
|
|
69
|
-
|
213
|
+
- Callable defaults accept the underlying type (v-kolesnikov)
|
70
214
|
|
71
215
|
[Compare v0.10.2...v0.10.3](https://github.com/dry-rb/dry-types/compare/v0.10.2...v0.10.3)
|
72
216
|
|
@@ -74,7 +218,7 @@
|
|
74
218
|
|
75
219
|
## Fixed
|
76
220
|
|
77
|
-
|
221
|
+
- Fixed `Type#optional?` for sum types (flash-gordon)
|
78
222
|
|
79
223
|
[Compare v0.10.1...v0.10.2](https://github.com/dry-rb/dry-types/compare/v0.10.1...v0.10.2)
|
80
224
|
|
@@ -82,13 +226,13 @@
|
|
82
226
|
|
83
227
|
## Added
|
84
228
|
|
85
|
-
|
86
|
-
|
229
|
+
- `Type#optional?` returns true if type is Sum and left is nil (GustavoCaso)
|
230
|
+
- `Type#pristine` returns a type without `meta` (flash-gordon)
|
87
231
|
|
88
232
|
## Fixed
|
89
233
|
|
90
|
-
|
91
|
-
|
234
|
+
- `meta` is used in type equality again (solnic)
|
235
|
+
- `Any` works correctly with meta again (flash-gordon)
|
92
236
|
|
93
237
|
[Compare v0.10.0...v0.10.1](https://github.com/dry-rb/dry-types/compare/v0.10.0...v0.10.1)
|
94
238
|
|
@@ -96,16 +240,16 @@
|
|
96
240
|
|
97
241
|
## Added
|
98
242
|
|
99
|
-
|
243
|
+
- Types can be used in `case` statements now (GustavoCaso)
|
100
244
|
|
101
245
|
## Fixed
|
102
246
|
|
103
|
-
|
247
|
+
- Return original value when Date.parse raises a RangeError (jviney)
|
104
248
|
|
105
249
|
## Changed
|
106
250
|
|
107
|
-
|
108
|
-
|
251
|
+
- Meta data are now stored separately from options (flash-gordon)
|
252
|
+
- `Types::Object` was renamed to `Types::Any` (flash-gordon)
|
109
253
|
|
110
254
|
[Compare v0.9.4...v0.10.0](https://github.com/dry-rb/dry-types/compare/v0.9.4...v0.10.0)
|
111
255
|
|
@@ -113,7 +257,7 @@
|
|
113
257
|
|
114
258
|
## Added
|
115
259
|
|
116
|
-
|
260
|
+
- Added `Types::Object` which passes an object of any type (flash-gordon)
|
117
261
|
|
118
262
|
[Compare v0.9.3...v0.9.4](https://github.com/dry-rb/dry-types/compare/v0.9.3...v0.9.4)
|
119
263
|
|
@@ -121,7 +265,7 @@
|
|
121
265
|
|
122
266
|
## Fixed
|
123
267
|
|
124
|
-
|
268
|
+
- Updated to dry-core >= 0.2.1 (ruby warnings are gone) (flash-gordon)
|
125
269
|
|
126
270
|
[Compare v0.9.2...v0.9.3](https://github.com/dry-rb/dry-types/compare/v0.9.2...v0.9.3)
|
127
271
|
|
@@ -129,11 +273,11 @@
|
|
129
273
|
|
130
274
|
## Added
|
131
275
|
|
132
|
-
|
276
|
+
- Support for `"Y"` and `"N"` as `true` and `false` values, respectively (scare21410)
|
133
277
|
|
134
278
|
## Changed
|
135
279
|
|
136
|
-
|
280
|
+
- Optimized object allocation in hash schemas, resulting in up to 25% speed boost (davydovanton)
|
137
281
|
|
138
282
|
[Compare v0.9.1...v0.9.2](https://github.com/dry-rb/dry-types/compare/v0.9.1...v0.9.2)
|
139
283
|
|
@@ -141,11 +285,11 @@
|
|
141
285
|
|
142
286
|
## Fixed
|
143
287
|
|
144
|
-
|
288
|
+
- `Hash#strict_with_defaults` properly evaluates callable defaults (bolshakov)
|
145
289
|
|
146
290
|
## Changed
|
147
291
|
|
148
|
-
|
292
|
+
- `Hash#weak` accepts Hash-descendants again (solnic)
|
149
293
|
|
150
294
|
[Compare v0.9.0...v0.9.1](https://github.com/dry-rb/dry-types/compare/v0.9.0...v0.9.1)
|
151
295
|
|
@@ -153,23 +297,23 @@
|
|
153
297
|
|
154
298
|
## Added
|
155
299
|
|
156
|
-
|
157
|
-
|
300
|
+
- `Hash#strict_with_defaults` which validates presence of all required keys and respects default types for missing _values_ (backus)
|
301
|
+
- `Type#constrained?` method (flash-gordon)
|
158
302
|
|
159
303
|
## Fixed
|
160
304
|
|
161
|
-
|
162
|
-
|
163
|
-
|
305
|
+
- Summing two constrained types works correctly (flash-gordon)
|
306
|
+
- `Types::Array::Member#valid?` in cases where member type is a constraint (solnic)
|
307
|
+
- `Hash::Schema#try` handles exceptions properly and returns a failure object (solnic)
|
164
308
|
|
165
309
|
## Changed
|
166
310
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
311
|
+
- [BREAKING] Renamed `Hash##{schema=>permissive}` (backus)
|
312
|
+
- [BREAKING] `dry-monads` dependency was made optional, Maybe types are available after `Dry::Types.load_extensions(:maybe)` (flash-gordon)
|
313
|
+
- [BREAKING] `Dry::Types::Struct` and `Dry::Types::Value` have been extracted to [`dry-struct`](https://github.com/dry-rb/dry-struct) (backus)
|
314
|
+
- `Types::Form::Bool` supports upcased true/false values (kirs)
|
315
|
+
- `Types::Form::{Date,DateTime,Time}` fail gracefully for invalid input (padde)
|
316
|
+
- ice_nine dependency has been dropped as it was required by Struct only (flash-gordon)
|
173
317
|
|
174
318
|
[Compare v0.8.1...v0.9.0](https://github.com/dry-rb/dry-types/compare/v0.8.1...v0.9.0)
|
175
319
|
|
@@ -177,8 +321,8 @@
|
|
177
321
|
|
178
322
|
## Fixed
|
179
323
|
|
180
|
-
|
181
|
-
|
324
|
+
- Compiler no longer chokes on type nodes without args (solnic)
|
325
|
+
- Removed `bin/console` from gem package (solnic)
|
182
326
|
|
183
327
|
[Compare v0.8.0...v0.8.1](https://github.com/dry-rb/dry-types/compare/v0.8.0...v0.8.1)
|
184
328
|
|
@@ -186,19 +330,19 @@
|
|
186
330
|
|
187
331
|
## Added
|
188
332
|
|
189
|
-
|
190
|
-
|
191
|
-
|
333
|
+
- `Struct` now implements `Type` interface so ie `SomeStruct | String` works now (flash-gordon)
|
334
|
+
- `:weak` Hash constructor which can partially coerce a hash even when it includes invalid values (solnic)
|
335
|
+
- Types include `Dry::Equalizer` now (flash-gordon)
|
192
336
|
|
193
337
|
## Fixed
|
194
338
|
|
195
|
-
|
196
|
-
|
339
|
+
- `Struct#to_hash` descends into arrays too (nepalez)
|
340
|
+
- `Default#with` works now (flash-gordon)
|
197
341
|
|
198
342
|
## Changed
|
199
343
|
|
200
|
-
|
201
|
-
|
344
|
+
- `:symbolized` hash schema is now based on `:weak` schema (solnic)
|
345
|
+
- `Struct::Value` instances are now **deeply frozen** via ice_nine (backus)
|
202
346
|
|
203
347
|
[Compare v0.7.2...v0.8.0](https://github.com/dry-rb/dry-types/compare/v0.7.2...v0.8.0)
|
204
348
|
|
@@ -274,32 +418,32 @@ Renamed from `dry-data` to `dry-types` and:
|
|
274
418
|
|
275
419
|
## Added
|
276
420
|
|
277
|
-
|
421
|
+
- `Dry::Types.module` which returns a namespace for inclusion which has all
|
278
422
|
built-in types defined as constants (solnic)
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
423
|
+
- `Hash#schema` supports default values now (solnic)
|
424
|
+
- `Hash#symbolized` passes through keys that are already symbols (solnic)
|
425
|
+
- `Struct.new` uses an empty hash by default as input (solnic)
|
426
|
+
- `Struct.constructor_type` macro can be used to change attributes constructor (solnic)
|
427
|
+
- `default` accepts a block now for dynamic values (solnic)
|
428
|
+
- `Types.register_class` accepts a second arg which is the name of the class'
|
285
429
|
constructor method, defaults to `:new` (solnic)
|
286
430
|
|
287
431
|
## Fixed
|
288
432
|
|
289
|
-
|
290
|
-
|
291
|
-
|
433
|
+
- `Struct` will simply pass-through the input if it is already a struct (solnic)
|
434
|
+
- `default` will raise if a value violates constraints (solnic)
|
435
|
+
- Evaluating a default value tries to use type's constructor which makes it work
|
292
436
|
with types that may coerce an input into nil (solnic)
|
293
|
-
|
294
|
-
|
295
|
-
|
437
|
+
- `enum` works just fine with integer-values (solnic)
|
438
|
+
- `enum` + `default` works just fine (solnic)
|
439
|
+
- `Optional` no longer responds to `primitive` as it makes no sense since there's
|
296
440
|
no single primitive for an optional value (solnic)
|
297
|
-
|
441
|
+
- `Optional` passes-through a value which is already a maybe (solnic)
|
298
442
|
|
299
443
|
## Changed
|
300
444
|
|
301
|
-
|
302
|
-
|
445
|
+
- `Dry::Types::Definition` is now the base type definition object (solnic)
|
446
|
+
- `Dry::Types::Constructor` is now a type definition with a constructor function (solnic)
|
303
447
|
|
304
448
|
[Compare v0.5.1...v0.6.0](https://github.com/dry-rb/dry-types/compare/v0.5.1...v0.6.0)
|
305
449
|
|
@@ -307,9 +451,9 @@ Renamed from `dry-data` to `dry-types` and:
|
|
307
451
|
|
308
452
|
## Added
|
309
453
|
|
310
|
-
|
454
|
+
- `Dry::Data::Type#safe` for types which can skip constructor when primitive does
|
311
455
|
not match input's class (solnic)
|
312
|
-
|
456
|
+
- `form.array` and `form.hash` safe types (solnic)
|
313
457
|
|
314
458
|
[Compare v0.5.0...v0.5.1](https://github.com/dry-rb/dry-types/compare/v0.5.0...v0.5.1)
|
315
459
|
|
@@ -317,20 +461,20 @@ Renamed from `dry-data` to `dry-types` and:
|
|
317
461
|
|
318
462
|
## Added
|
319
463
|
|
320
|
-
|
464
|
+
- `Type#default` interface for defining a type with a default value (solnic)
|
321
465
|
|
322
466
|
## Changed
|
323
467
|
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
468
|
+
- [BREAKING] `Dry::Data::Type.new` accepts constructor and _options_ now (solnic)
|
469
|
+
- Renamed `Dry::Data::Type::{Enum,Constrained}` => `Dry::Data::{Enum,Constrained}` (solnic)
|
470
|
+
- `dry-logic` is now a dependency for constrained types (solnic)
|
471
|
+
- Constrained types are now always available (solnic)
|
472
|
+
- `strict.*` category uses constrained types with `:type?` predicate (solnic)
|
473
|
+
- `SumType#call` no longer needs to rescue from `TypeError` (solnic)
|
330
474
|
|
331
475
|
## Fixed
|
332
476
|
|
333
|
-
|
477
|
+
- `attribute` raises proper error when type definition is missing (solnic)
|
334
478
|
|
335
479
|
[Compare v0.4.2...v0.5.0](https://github.com/dry-rb/dry-types/compare/v0.4.2...v0.5.0)
|
336
480
|
|
@@ -338,11 +482,11 @@ Renamed from `dry-data` to `dry-types` and:
|
|
338
482
|
|
339
483
|
## Added
|
340
484
|
|
341
|
-
|
485
|
+
- Support for arrays in type compiler (solnic)
|
342
486
|
|
343
487
|
## Changed
|
344
488
|
|
345
|
-
|
489
|
+
- Array member uses type objects now rather than just their constructors (solnic)
|
346
490
|
|
347
491
|
[Compare v0.4.1...v0.4.2](https://github.com/dry-rb/dry-types/compare/v0.4.1...v0.4.2)
|
348
492
|
|
@@ -350,12 +494,12 @@ Renamed from `dry-data` to `dry-types` and:
|
|
350
494
|
|
351
495
|
## Added
|
352
496
|
|
353
|
-
|
354
|
-
|
497
|
+
- Support for sum-types with constraint type (solnic)
|
498
|
+
- `Dry::Data::Type#optional` for defining optional types (solnic)
|
355
499
|
|
356
500
|
## Changed
|
357
501
|
|
358
|
-
|
502
|
+
- `Dry::Data['optional']` was **removed** in favor of `Dry::Data::Type#optional` (solnic)
|
359
503
|
|
360
504
|
[Compare v0.3.2...v0.4.0](https://github.com/dry-rb/dry-types/compare/v0.3.2...v0.4.0)
|
361
505
|
|
@@ -363,11 +507,11 @@ Renamed from `dry-data` to `dry-types` and:
|
|
363
507
|
|
364
508
|
## Added
|
365
509
|
|
366
|
-
|
510
|
+
- `Dry::Data::Value` which works like a struct but is a value object with equalizer (solnic)
|
367
511
|
|
368
512
|
## Fixed
|
369
513
|
|
370
|
-
|
514
|
+
- Added missing require for `dry-equalizer` (solnic)
|
371
515
|
|
372
516
|
[Compare v0.3.1...v0.3.2](https://github.com/dry-rb/dry-types/compare/v0.3.1...v0.3.2)
|
373
517
|
|
@@ -375,7 +519,7 @@ Renamed from `dry-data` to `dry-types` and:
|
|
375
519
|
|
376
520
|
## Changed
|
377
521
|
|
378
|
-
|
522
|
+
- Removed require of constrained type and make it optional (solnic)
|
379
523
|
|
380
524
|
[Compare v0.3.0...v0.3.1](https://github.com/dry-rb/dry-types/compare/v0.3.0...v0.3.1)
|
381
525
|
|
@@ -383,11 +527,11 @@ Renamed from `dry-data` to `dry-types` and:
|
|
383
527
|
|
384
528
|
## Added
|
385
529
|
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
530
|
+
- `Type#constrained` interface for defining constrained types (solnic)
|
531
|
+
- `Dry::Data` can be configured with a type namespace (solnic)
|
532
|
+
- `Dry::Data.finalize` can be used to define types as constants under configured namespace (solnic)
|
533
|
+
- `Dry::Data::Type#enum` for defining an enum from a specific type (solnic)
|
534
|
+
- New types: `symbol` and `class` along with their `strict` versions (solnic)
|
391
535
|
|
392
536
|
[Compare v0.2.1...v0.3.0](https://github.com/dry-rb/dry-types/compare/v0.2.1...v0.3.0)
|
393
537
|
|
@@ -395,15 +539,15 @@ Renamed from `dry-data` to `dry-types` and:
|
|
395
539
|
|
396
540
|
## Added
|
397
541
|
|
398
|
-
|
542
|
+
- Type compiler supports nested hashes now (solnic)
|
399
543
|
|
400
544
|
## Fixed
|
401
545
|
|
402
|
-
|
546
|
+
- `form.bool` sum is using correct right-side `form.false` type (solnic)
|
403
547
|
|
404
548
|
## Changed
|
405
549
|
|
406
|
-
|
550
|
+
- Improved structure of the ast (solnic)
|
407
551
|
|
408
552
|
[Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-types/compare/v0.2.0...v0.2.1)
|
409
553
|
|
@@ -411,13 +555,13 @@ Renamed from `dry-data` to `dry-types` and:
|
|
411
555
|
|
412
556
|
## Added
|
413
557
|
|
414
|
-
|
415
|
-
|
416
|
-
|
558
|
+
- `form.nil` which coerces empty strings to `nil` (solnic)
|
559
|
+
- `bool` sum-type (true | false) (solnic)
|
560
|
+
- Type compiler supports sum-types now (solnic)
|
417
561
|
|
418
562
|
## Changed
|
419
563
|
|
420
|
-
|
564
|
+
- Constructing optional types uses the new `Dry::Data["optional"]` built-in type (solnic)
|
421
565
|
|
422
566
|
[Compare v0.1.0...v0.2.0](https://github.com/dry-rb/dry-types/compare/v0.1.0...v0.2.0)
|
423
567
|
|
@@ -425,12 +569,12 @@ Renamed from `dry-data` to `dry-types` and:
|
|
425
569
|
|
426
570
|
## Added
|
427
571
|
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
572
|
+
- `form.*` coercible types (solnic)
|
573
|
+
- `Type::Hash#strict` for defining hashes with a strict schema (solnic)
|
574
|
+
- `Type::Hash#symbolized` for defining hashes that will symbolize keys (solnic)
|
575
|
+
- `Dry::Data.register_class` short-cut interface for registering a class and
|
432
576
|
setting its `.new` method as the constructor (solnic)
|
433
|
-
|
577
|
+
- `Dry::Data::Compiler` for building a type from a simple ast (solnic)
|
434
578
|
|
435
579
|
[Compare v0.0.1...HEAD](https://github.com/dry-rb/dry-types/compare/v0.0.1...HEAD)
|
436
580
|
|
data/CONTRIBUTING.md
CHANGED
@@ -10,7 +10,7 @@ Report a feature request **only after discussing it first on [discourse.dry-rb.o
|
|
10
10
|
|
11
11
|
## Reporting questions, support requests, ideas, concerns etc.
|
12
12
|
|
13
|
-
**PLEASE DON'T** - use [discourse.dry-rb.org](
|
13
|
+
**PLEASE DON'T** - use [discourse.dry-rb.org](https://discourse.dry-rb.org) instead.
|
14
14
|
|
15
15
|
# Pull Request Guidelines
|
16
16
|
|