dry-types 1.2.2 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +405 -225
- data/LICENSE +1 -1
- data/README.md +14 -12
- data/dry-types.gemspec +26 -31
- data/lib/dry-types.rb +1 -1
- data/lib/dry/types.rb +55 -40
- data/lib/dry/types/any.rb +2 -2
- data/lib/dry/types/array.rb +2 -2
- data/lib/dry/types/array/constructor.rb +1 -1
- data/lib/dry/types/array/member.rb +1 -1
- data/lib/dry/types/builder.rb +70 -18
- data/lib/dry/types/builder_methods.rb +1 -2
- data/lib/dry/types/coercions.rb +0 -17
- data/lib/dry/types/coercions/json.rb +22 -5
- data/lib/dry/types/coercions/params.rb +20 -3
- data/lib/dry/types/compiler.rb +10 -10
- data/lib/dry/types/constrained.rb +6 -9
- data/lib/dry/types/constraints.rb +3 -3
- data/lib/dry/types/constructor.rb +40 -6
- data/lib/dry/types/constructor/function.rb +48 -32
- data/lib/dry/types/constructor/wrapper.rb +94 -0
- data/lib/dry/types/container.rb +1 -1
- data/lib/dry/types/core.rb +15 -13
- data/lib/dry/types/decorator.rb +2 -9
- data/lib/dry/types/default.rb +14 -1
- data/lib/dry/types/enum.rb +4 -3
- data/lib/dry/types/errors.rb +1 -1
- data/lib/dry/types/extensions.rb +2 -2
- data/lib/dry/types/extensions/maybe.rb +18 -17
- data/lib/dry/types/extensions/monads.rb +1 -1
- data/lib/dry/types/fn_container.rb +1 -1
- data/lib/dry/types/hash.rb +9 -15
- data/lib/dry/types/hash/constructor.rb +1 -1
- data/lib/dry/types/inflector.rb +1 -1
- data/lib/dry/types/json.rb +15 -15
- data/lib/dry/types/lax.rb +3 -6
- data/lib/dry/types/map.rb +2 -2
- data/lib/dry/types/meta.rb +3 -3
- data/lib/dry/types/module.rb +6 -6
- data/lib/dry/types/nominal.rb +11 -11
- data/lib/dry/types/params.rb +31 -28
- data/lib/dry/types/predicate_inferrer.rb +52 -11
- data/lib/dry/types/predicate_registry.rb +1 -1
- data/lib/dry/types/primitive_inferrer.rb +1 -1
- data/lib/dry/types/printer.rb +25 -25
- data/lib/dry/types/result.rb +3 -3
- data/lib/dry/types/schema.rb +26 -13
- data/lib/dry/types/schema/key.rb +15 -6
- data/lib/dry/types/spec/types.rb +65 -42
- data/lib/dry/types/sum.rb +6 -5
- data/lib/dry/types/type.rb +1 -1
- data/lib/dry/types/version.rb +1 -1
- metadata +27 -78
- data/.codeclimate.yml +0 -12
- data/.github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md +0 -10
- data/.github/ISSUE_TEMPLATE/---bug-report.md +0 -30
- data/.github/ISSUE_TEMPLATE/---feature-request.md +0 -18
- data/.github/workflows/custom_ci.yml +0 -76
- data/.github/workflows/docsite.yml +0 -34
- data/.github/workflows/sync_configs.yml +0 -34
- data/.gitignore +0 -11
- data/.rspec +0 -4
- data/.rubocop.yml +0 -92
- data/.yardopts +0 -9
- data/CODE_OF_CONDUCT.md +0 -13
- data/CONTRIBUTING.md +0 -29
- data/Gemfile +0 -34
- data/Rakefile +0 -22
- data/benchmarks/hash_schemas.rb +0 -55
- data/benchmarks/lax_schema.rb +0 -15
- data/benchmarks/profile_invalid_input.rb +0 -15
- data/benchmarks/profile_lax_schema_valid.rb +0 -16
- data/benchmarks/profile_valid_input.rb +0 -15
- data/benchmarks/schema_valid_vs_invalid.rb +0 -21
- data/benchmarks/setup.rb +0 -17
- data/docsite/source/array-with-member.html.md +0 -13
- data/docsite/source/built-in-types.html.md +0 -116
- data/docsite/source/constraints.html.md +0 -31
- data/docsite/source/custom-types.html.md +0 -93
- data/docsite/source/default-values.html.md +0 -91
- data/docsite/source/enum.html.md +0 -69
- data/docsite/source/extensions.html.md +0 -15
- data/docsite/source/extensions/maybe.html.md +0 -57
- data/docsite/source/extensions/monads.html.md +0 -61
- data/docsite/source/getting-started.html.md +0 -57
- data/docsite/source/hash-schemas.html.md +0 -169
- data/docsite/source/index.html.md +0 -156
- data/docsite/source/map.html.md +0 -17
- data/docsite/source/optional-values.html.md +0 -35
- data/docsite/source/sum.html.md +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c7c872991cdfc4269f8de895e51cd19b129f6ef86fb78b48ff5ca5bb1e811d8
|
4
|
+
data.tar.gz: b3600454a14b4dde65512f8c55f4c2a9ec1e9293d45364cde763bb0e1185fa9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f0286b20cd4c40478587e083ff4ef7fb6bb39e66ee01864c7f5710697f30378742899ae509181be215096cf76b26d2c1aa14e4b1f2bd651058911e201d5281f
|
7
|
+
data.tar.gz: 2a1ae064396c3074bf28d90fe94867b62b2c787ea0798a7f934bc81b2232b46616f7ee71ad7caaa4612712f1ff306f9f255969b0e4ad67f28e12925fd77dd658
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,132 @@
|
|
1
|
-
|
1
|
+
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
2
2
|
|
3
|
-
##
|
3
|
+
## 1.5.1 2021-02-16
|
4
4
|
|
5
|
-
- `Types.Contructor` doesn't re-wrap class instances implementing type interface, this fixes some quirks in dry-struct (flash-gordon)
|
6
5
|
|
7
|
-
|
6
|
+
### Fixed
|
7
|
+
|
8
|
+
- Add missing requires for internal usage of `Dry::Equalizer` (@timriley in #418)
|
9
|
+
|
10
|
+
|
11
|
+
[Compare v1.5.0...v1.5.1](https://github.com/dry-rb/dry-types/compare/v1.5.0...v1.5.1)
|
12
|
+
|
13
|
+
## 1.5.0 2021-01-21
|
14
|
+
|
15
|
+
|
16
|
+
### Added
|
17
|
+
|
18
|
+
- Wrapping constructor types :tada: (@flash-gordon)
|
19
|
+
|
20
|
+
Constructor blocks can have a second argument.
|
21
|
+
The second argument is the underlying type itself:
|
22
|
+
```ruby
|
23
|
+
age_from_year = Dry::Types['coercible.integer'].constructor do |input, type|
|
24
|
+
Date.today.year - type.(input)
|
25
|
+
end
|
26
|
+
age_from_year.('2000') # => 21
|
27
|
+
```
|
28
|
+
With wrapping constructors you have control over "type application". You can even
|
29
|
+
run it more than once:
|
30
|
+
```ruby
|
31
|
+
inc = Dry::Types['integer'].constructor(&:succ)
|
32
|
+
inc2x = inc.constructor { _2.(_2.(_2.(_1))) }
|
33
|
+
inc2x.(10) # => 13
|
34
|
+
```
|
35
|
+
- Fallbacks :tada: (@flash-gordon)
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
age = Dry::Types['coercible.ineger'].fallback(18)
|
39
|
+
age.('10') # => 10
|
40
|
+
age.('20') # => 20
|
41
|
+
age.('abc') # => 18
|
42
|
+
```
|
43
|
+
|
44
|
+
Fallbacks are different from default values: the later will be evaluated
|
45
|
+
only when *no input* provided.
|
46
|
+
|
47
|
+
Under the hood, `.fallback` creates a wrapping constructor.
|
48
|
+
- `params.string` as an alias for `strict.string`. This addition should be non-breaking (@flash-gordon)
|
49
|
+
- API for defining custom type builders similar to `.default`, `.constructor`, or `.optional` (@flash-gordon)
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
# Making an alias for `.fallback`
|
53
|
+
Dry::Types.define_builder(:or) { |type, v| type.fallback(v) }
|
54
|
+
|
55
|
+
# Using new builder
|
56
|
+
type = Dry::Types['integer'].or(-273)
|
57
|
+
type.(:invalid) # => -273
|
58
|
+
```
|
59
|
+
|
60
|
+
### Changed
|
61
|
+
|
62
|
+
- Inferring predicates from class names is deprecated. It's very unlikely your code depends on it,
|
63
|
+
however, if it does, you'll get an exception with instructions. (@flash-gordon)
|
64
|
+
|
65
|
+
If you don't rely on inferring, just disable it with:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
Dry::Types::PredicateInferrer::Compiler.infer_predicate_by_class_name false
|
69
|
+
```
|
70
|
+
|
71
|
+
Otherwise, enable it explicitly:
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
Dry::Types::PredicateInferrer::Compiler.infer_predicate_by_class_name true
|
75
|
+
```
|
76
|
+
|
77
|
+
[Compare v1.4.0...v1.5.0](https://github.com/dry-rb/dry-types/compare/v1.4.0...v1.5.0)
|
78
|
+
|
79
|
+
## 1.4.0 2020-03-09
|
80
|
+
|
81
|
+
|
82
|
+
### Fixed
|
83
|
+
|
84
|
+
- `json.nil` no longer coerces empty strings to `nil`. It was a long-standing
|
85
|
+
bug that for some reason remained unnoticed for years. Technically,
|
86
|
+
this may be a breaking change for JSON schemas described with dry-schema (@flash-gordon)
|
87
|
+
|
88
|
+
|
89
|
+
[Compare v1.3.1...v1.4.0](https://github.com/dry-rb/dry-types/compare/v1.3.1...v1.4.0)
|
90
|
+
|
91
|
+
## 1.3.1 2020-02-17
|
92
|
+
|
93
|
+
|
94
|
+
### Changed
|
95
|
+
|
96
|
+
- Predicate inferrer now returns `hash?` for hash schemas. Note, it doesn't spit more complex preds because we have different plans for dry-schema (@flash-gordon)
|
97
|
+
|
98
|
+
[Compare v1.3.0...v1.3.1](https://github.com/dry-rb/dry-types/compare/v1.3.0...v1.3.1)
|
99
|
+
|
100
|
+
## 1.3.0 2020-02-10
|
101
|
+
|
102
|
+
|
103
|
+
### Added
|
104
|
+
|
105
|
+
- `Schema#merge` for merging two hash schemas (@waiting-for-dev)
|
106
|
+
- Aliases for `.constructor` to non-constructor types. Now you can call `.prepend`/`.append` without silly checks for the type being a constructor (flash-gordon)
|
107
|
+
```ruby
|
108
|
+
(Dry::Types['integer'].prepend(-> { _1 + 1 })).(1) # => 2
|
109
|
+
(Dry::Types['coercible.integer'] >> -> { _1 * 2 }).('99') # => 198
|
110
|
+
```
|
111
|
+
- `Hash::Schema#clear` returns a schema with the same options but without keys
|
112
|
+
- Optional namespace now includes strict types by default (@flash-gordon)
|
113
|
+
|
114
|
+
### Fixed
|
115
|
+
|
116
|
+
- `Schema::Key#optional` returns an instance of `Schema::Key` as it should have done
|
117
|
+
- Composition with function handling exceptions. This could occasionally lead to unexpected exceptions (@flash-gordon)
|
118
|
+
|
119
|
+
|
120
|
+
[Compare v1.2.2...v1.3.0](https://github.com/dry-rb/dry-types/compare/v1.2.2...v1.3.0)
|
121
|
+
|
122
|
+
## 1.2.2 2019-12-14
|
123
|
+
|
124
|
+
|
125
|
+
### Fixed
|
126
|
+
|
127
|
+
- `Types.Contructor` doesn't re-wrap class instances implementing type interface, this fixes some quirks in dry-struct (@flash-gordon)
|
128
|
+
|
129
|
+
### Changed
|
8
130
|
|
9
131
|
- Types now use immutable equalizers. This should improve performance in certain cases e.g. in ROM (flash-gordon)
|
10
132
|
- Attempting to use non-symbol keys in hash schemas raises an error. We always supported only symbols as keys but there was no check, now it'll throw an argument error. If you want to convert strings to symbols, use `Hash#with_key_transform` (flash-gordon)
|
@@ -12,28 +134,21 @@
|
|
12
134
|
|
13
135
|
[Compare v1.2.1...v1.2.2](https://github.com/dry-rb/dry-types/compare/v1.2.1...v1.2.2)
|
14
136
|
|
15
|
-
|
137
|
+
## 1.2.1 2019-11-07
|
138
|
+
|
16
139
|
|
17
|
-
|
140
|
+
### Fixed
|
18
141
|
|
19
142
|
- Fix keyword warnings reported by Ruby 2.7 (flash-gordon)
|
20
143
|
- Error type in failing case in `Array::Member` (esparta)
|
21
144
|
|
22
|
-
[Compare v1.2.0...v1.2.1](https://github.com/dry-rb/dry-types/compare/v1.2.0...v1.2.1)
|
23
|
-
|
24
|
-
# 1.2.0 2019-10-06
|
25
145
|
|
26
|
-
|
27
|
-
|
28
|
-
- `Dry::Types.[]` used to work with classes, now it's deprecated (flash-gordon)
|
146
|
+
[Compare v1.2.0...v1.2.1](https://github.com/dry-rb/dry-types/compare/v1.2.0...v1.2.1)
|
29
147
|
|
30
|
-
##
|
148
|
+
## 1.2.0 2019-10-06
|
31
149
|
|
32
|
-
- Bug with using a `Bool`-named struct as a schema key (flash-gordon)
|
33
|
-
- A bunch of issues related to using `meta` on complex types (flash-gordon)
|
34
|
-
- `Types.Constructor(...)` returns a `Types::Array` as it should (flash-gordon)
|
35
150
|
|
36
|
-
|
151
|
+
### Added
|
37
152
|
|
38
153
|
- `Optional::Params` types that coerce empty strings to `nil` (flash-gordon)
|
39
154
|
```ruby
|
@@ -79,19 +194,32 @@
|
|
79
194
|
end
|
80
195
|
```
|
81
196
|
|
197
|
+
### Fixed
|
198
|
+
|
199
|
+
- Bug with using a `Bool`-named struct as a schema key (flash-gordon)
|
200
|
+
- A bunch of issues related to using `meta` on complex types (flash-gordon)
|
201
|
+
- `Types.Constructor(...)` returns a `Types::Array` as it should (flash-gordon)
|
202
|
+
|
203
|
+
### Changed
|
204
|
+
|
205
|
+
- `Dry::Types.[]` used to work with classes, now it's deprecated (flash-gordon)
|
206
|
+
|
82
207
|
[Compare v1.1.1...v1.2.0](https://github.com/dry-rb/dry-types/compare/v1.1.1...v1.2.0)
|
83
208
|
|
84
|
-
|
209
|
+
## 1.1.1 2019-07-26
|
210
|
+
|
85
211
|
|
86
|
-
|
212
|
+
### Fixed
|
87
213
|
|
88
214
|
- A bug where meta was lost for lax array types (flash-gordon)
|
89
215
|
|
216
|
+
|
90
217
|
[Compare v1.1.0...v1.1.1](https://github.com/dry-rb/dry-types/compare/v1.1.0...v1.1.1)
|
91
218
|
|
92
|
-
|
219
|
+
## 1.1.0 2019-07-02
|
93
220
|
|
94
|
-
|
221
|
+
|
222
|
+
### Added
|
95
223
|
|
96
224
|
- New builder method `Interface` constructs a type which accepts objects that respond to the given methods (waiting-for-dev)
|
97
225
|
```ruby
|
@@ -102,18 +230,20 @@
|
|
102
230
|
```
|
103
231
|
- New types: `coercible.symbol`, `params.symbol`, and `json.symbol`, all use `.to_sym` for coercion (waiting-for-dev)
|
104
232
|
|
105
|
-
|
233
|
+
### Fixed
|
106
234
|
|
107
235
|
- Converting schema keys to maybe types (flash-gordon)
|
108
236
|
- Using `Schema#key` and `Array#member` on constuctors (flash-gordon)
|
109
237
|
- Using `meta(omittable: true)` within `transform_types` works again but produces a warning, please migrate to `.omittable` or `.required(false)` (flash-gordon)
|
110
238
|
- Bug with a constructror defined on top of enum (flash-gordon)
|
111
239
|
|
240
|
+
|
112
241
|
[Compare v1.0.1...v1.1.0](https://github.com/dry-rb/dry-types/compare/v1.0.1...v1.1.0)
|
113
242
|
|
114
|
-
|
243
|
+
## 1.0.1 2019-06-04
|
115
244
|
|
116
|
-
|
245
|
+
|
246
|
+
### Added
|
117
247
|
|
118
248
|
- In a case of failure the constructor block can now pass a different value (flash-gordon)
|
119
249
|
```ruby
|
@@ -126,42 +256,13 @@
|
|
126
256
|
```
|
127
257
|
- `Schema#strict` now accepts an boolean argument. If `fales` is passed this will turn a strict schema into a non-strict one (flash-gordon)
|
128
258
|
|
129
|
-
[Compare v1.0.0...v1.0.1](https://github.com/dry-rb/dry-types/compare/v1.0.0...v1.0.1)
|
130
|
-
|
131
|
-
# 1.0.0 2019-04-23
|
132
|
-
|
133
|
-
## Changed
|
134
|
-
|
135
|
-
- [BREAKING] Behavior of built-in constructor types was changed to be more strict. They will always raise an error on failed coercion (flash-gordon)
|
136
|
-
Compare:
|
137
|
-
|
138
|
-
```ruby
|
139
|
-
# 0.15.0
|
140
|
-
Types::Params::Integer.('foo')
|
141
|
-
# => "foo"
|
142
|
-
|
143
|
-
# 1.0.0
|
144
|
-
Types::Params::Integer.('foo')
|
145
|
-
# => Dry::Types::CoercionError: invalid value for Integer(): "foo"
|
146
|
-
```
|
147
|
-
|
148
|
-
To handle coercion errors `Type#call` now yields a block:
|
149
|
-
|
150
|
-
```ruby
|
151
|
-
Types::Params::Integer.('foo') { :invalid } # => :invalid
|
152
|
-
```
|
153
259
|
|
154
|
-
|
260
|
+
[Compare v1.0.0...v1.0.1](https://github.com/dry-rb/dry-types/compare/v1.0.0...v1.0.1)
|
155
261
|
|
156
|
-
|
157
|
-
- [BREAKING] Metadata is now pushed down to the decorated type. It is not likely you will notice a difference but this a breaking change that enables some use cases in rom related to the usage of default types in relations (flash-gordon)
|
158
|
-
- Nominal types are now completely unconstrained. This fixes some inconsistencies when using them with constraints. `Nominal#try` will always return a successful result, for the previous behavior use `Nominal#try_coerce` or switch to strict types with passing a block to `#call` (flash-gordon)
|
262
|
+
## 1.0.0 2019-04-23
|
159
263
|
|
160
|
-
## Performance improvements
|
161
264
|
|
162
|
-
|
163
|
-
|
164
|
-
## Added
|
265
|
+
### Added
|
165
266
|
|
166
267
|
- API for custom constructor types was enhanced. If you pass your own callable to `.constructor` it can have a block in its signature. If a block is passed, you must call it on failed coercion, otherwise raise a type coercion error (flash-gordon)
|
167
268
|
Example:
|
@@ -190,44 +291,40 @@
|
|
190
291
|
# => [1, 2, 3]
|
191
292
|
```
|
192
293
|
|
193
|
-
|
194
|
-
|
195
|
-
# 0.15.0 2019-03-22
|
294
|
+
### Changed
|
196
295
|
|
197
|
-
|
296
|
+
- [BREAKING] Behavior of built-in constructor types was changed to be more strict. They will always raise an error on failed coercion (flash-gordon)
|
297
|
+
Compare:
|
198
298
|
|
199
|
-
- [BREAKING] Internal representation of hash schemas was changed to be a simple list of key types (flash-gordon)
|
200
|
-
`Dry::Types::Hash#with_type_transform` now yields a key type instead of type + name:
|
201
|
-
```ruby
|
202
|
-
Dry::Types['strict.hash'].with_type_transform { |key| key.name == :age ? key.required(false) : key }
|
203
|
-
```
|
204
|
-
- [BREAKING] Definition types were renamed to nominal (flash-gordon)
|
205
|
-
- [BREAKING] Top-level types returned by `Dry::Types.[]` are now strict (flash-gordon)
|
206
299
|
```ruby
|
207
|
-
#
|
208
|
-
|
209
|
-
# =>
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
#
|
214
|
-
Dry::Types['nominal.integer']
|
215
|
-
# => #<Dry::Types[Nominal<Integer>]>
|
300
|
+
# 0.15.0
|
301
|
+
Types::Params::Integer.('foo')
|
302
|
+
# => "foo"
|
303
|
+
|
304
|
+
# 1.0.0
|
305
|
+
Types::Params::Integer.('foo')
|
306
|
+
# => Dry::Types::CoercionError: invalid value for Integer(): "foo"
|
216
307
|
```
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
Keep in mind `Dry.Types` uses strict types for top-level names, that is after
|
308
|
+
|
309
|
+
To handle coercion errors `Type#call` now yields a block:
|
310
|
+
|
221
311
|
```ruby
|
222
|
-
|
223
|
-
include Dry.Types
|
224
|
-
end
|
312
|
+
Types::Params::Integer.('foo') { :invalid } # => :invalid
|
225
313
|
```
|
226
|
-
`Types::Integer` is a strict type. If you want it to be nominal, use `include Dry.Types(default: :nominal)`. See other options below.
|
227
|
-
- `params.integer` now always converts strings to decimal numbers, this means `09` will be coerced to `9` (threw an error before) (skryukov)
|
228
|
-
- Ruby 2.3 is EOL and not officially supported. It may work but we don't test it.
|
229
314
|
|
230
|
-
|
315
|
+
This makes work with coercions more straightforward and way faster.
|
316
|
+
- [BREAKING] Safe types were renamed to Lax, this name better serves their purpose. The previous name is available but prints a warning (flash-gordon)
|
317
|
+
- [BREAKING] Metadata is now pushed down to the decorated type. It is not likely you will notice a difference but this a breaking change that enables some use cases in rom related to the usage of default types in relations (flash-gordon)
|
318
|
+
- Nominal types are now completely unconstrained. This fixes some inconsistencies when using them with constraints. `Nominal#try` will always return a successful result, for the previous behavior use `Nominal#try_coerce` or switch to strict types with passing a block to `#call` (flash-gordon)
|
319
|
+
- ## Performance improvements
|
320
|
+
- During the work on this release, a lot of performance improvements were made. dry-types 1.0 combined with dry-logic 1.0 are multiple times faster than dry-types 0.15 and dry-logic 0.5 for common cases including constraints checking and coercion (flash-gordon)
|
321
|
+
|
322
|
+
[Compare v0.15.0...v1.0.0](https://github.com/dry-rb/dry-types/compare/v0.15.0...v1.0.0)
|
323
|
+
|
324
|
+
## 0.15.0 2019-03-22
|
325
|
+
|
326
|
+
|
327
|
+
### Added
|
231
328
|
|
232
329
|
- Improved string representation of types (flash-gordon)
|
233
330
|
```ruby
|
@@ -285,7 +382,6 @@
|
|
285
382
|
# keys in user_schema are not required
|
286
383
|
user_schema = lax_hash.schema(name: 'string', age: 'integer')
|
287
384
|
```
|
288
|
-
|
289
385
|
- `Type#optional?` now recognizes more cases where `nil` is an allowed value (flash-gordon)
|
290
386
|
- `Constructor#{prepend,append}` with `<<` and `>>` as aliases. `Constructor#append` works the same way `Constructor#constrcutor` does. `Constuctor#prepend` chains functions in the reverse order, see examples (flash-gordon)
|
291
387
|
|
@@ -297,7 +393,6 @@
|
|
297
393
|
inc = to_int.prepend { |x| x + "2" }
|
298
394
|
inc.("1") # => "1" -> "12" -> 12
|
299
395
|
```
|
300
|
-
|
301
396
|
- Partial schema application for cases when you want to validate only a subset of keys (flash-gordon)
|
302
397
|
This is useful when you want to update a key or two in an already-validated hash. A perfect example is `Dry::Struct#new` where this feature is now used.
|
303
398
|
```ruby
|
@@ -307,87 +402,120 @@
|
|
307
402
|
value.merge(update)
|
308
403
|
```
|
309
404
|
|
310
|
-
|
405
|
+
### Fixed
|
311
406
|
|
312
407
|
- `Hash::Map` now behaves as a constrained type if its values are constrained (flash-gordon)
|
313
408
|
- `coercible.integer` now doesn't blow up on invalid strings (exterm)
|
314
409
|
|
315
|
-
|
410
|
+
### Changed
|
316
411
|
|
317
|
-
|
412
|
+
- [BREAKING] Internal representation of hash schemas was changed to be a simple list of key types (flash-gordon)
|
413
|
+
`Dry::Types::Hash#with_type_transform` now yields a key type instead of type + name:
|
414
|
+
```ruby
|
415
|
+
Dry::Types['strict.hash'].with_type_transform { |key| key.name == :age ? key.required(false) : key }
|
416
|
+
```
|
417
|
+
- [BREAKING] Definition types were renamed to nominal (flash-gordon)
|
418
|
+
- [BREAKING] Top-level types returned by `Dry::Types.[]` are now strict (flash-gordon)
|
419
|
+
```ruby
|
420
|
+
# before
|
421
|
+
Dry::Types['integer']
|
422
|
+
# => #<Dry::Types[Nominal<Integer>]>
|
423
|
+
# now
|
424
|
+
Dry::Types['integer']
|
425
|
+
# => <Dry::Types[Constrained<Nominal<Integer> rule=[type?(Integer)]>]>
|
426
|
+
# you can still access nominal types using namespace
|
427
|
+
Dry::Types['nominal.integer']
|
428
|
+
# => #<Dry::Types[Nominal<Integer>]>
|
429
|
+
```
|
430
|
+
- [BREAKING] Default values are not evaluated if the decorated type returns `nil`. They are triggered on `Undefined` instead (GustavoCaso + flash-gordon)
|
431
|
+
- [BREAKING] Support for old hash schemas was fully removed. This makes dry-types not compatible with dry-validation < 1.0 (flash-gordon)
|
432
|
+
- `Dry::Types.module` is deprecated in favor of `Dry.Types` (flash-gordon)
|
433
|
+
Keep in mind `Dry.Types` uses strict types for top-level names, that is after
|
434
|
+
```ruby
|
435
|
+
module Types
|
436
|
+
include Dry.Types
|
437
|
+
end
|
438
|
+
```
|
439
|
+
`Types::Integer` is a strict type. If you want it to be nominal, use `include Dry.Types(default: :nominal)`. See other options below.
|
440
|
+
- `params.integer` now always converts strings to decimal numbers, this means `09` will be coerced to `9` (threw an error before) (skryukov)
|
441
|
+
- Ruby 2.3 is EOL and not officially supported. It may work but we don't test it.
|
318
442
|
|
319
|
-
|
443
|
+
[Compare v0.14.1...v0.15.0](https://github.com/dry-rb/dry-types/compare/v0.14.1...v0.15.0)
|
444
|
+
|
445
|
+
## 0.14.1 2019-03-25
|
446
|
+
|
447
|
+
|
448
|
+
### Fixed
|
320
449
|
|
321
450
|
- `coercible.integer` now doesn't blow up on invalid strings (exterm)
|
322
451
|
|
452
|
+
|
323
453
|
[Compare v0.14.0...v0.14.1](https://github.com/dry-rb/dry-types/compare/v0.14.0...v0.14.1)
|
324
454
|
|
325
|
-
|
455
|
+
## 0.14.0 2019-01-29
|
326
456
|
|
327
|
-
## Changed
|
328
457
|
|
329
|
-
|
330
|
-
- `dry-logic` was updated to `~> 0.5` (solnic)
|
331
|
-
|
332
|
-
## Fixed
|
458
|
+
### Fixed
|
333
459
|
|
334
460
|
- `valid?` works correctly with constructors now (cgeorgii)
|
335
461
|
|
462
|
+
### Changed
|
463
|
+
|
464
|
+
- [BREAKING] Support for Ruby 2.2 was dropped. It reached EOL on March 31, 2018.
|
465
|
+
- `dry-logic` was updated to `~> 0.5` (solnic)
|
466
|
+
|
336
467
|
[Compare v0.13.4...v0.14.0](https://github.com/dry-rb/dry-types/compare/v0.13.4...v0.14.0)
|
337
468
|
|
338
|
-
|
469
|
+
## 0.13.4 2018-12-21
|
470
|
+
|
339
471
|
|
340
|
-
|
472
|
+
### Fixed
|
341
473
|
|
342
474
|
- Fixed warnings about keyword arguments from Ruby 2.6. See https://bugs.ruby-lang.org/issues/14183 for all the details (flash-gordon)
|
343
475
|
|
344
|
-
# v0.13.3 2018-11-25
|
345
476
|
|
346
|
-
|
477
|
+
[Compare v0.13.3...v0.13.4](https://github.com/dry-rb/dry-types/compare/v0.13.3...v0.13.4)
|
478
|
+
|
479
|
+
## 0.13.3 2018-11-25
|
480
|
+
|
481
|
+
|
482
|
+
### Fixed
|
347
483
|
|
348
484
|
- `Dry::Types::Hash#try` returns `Failure` instead of throwing an exception on missing keys (GustavoCaso)
|
349
485
|
|
486
|
+
|
350
487
|
[Compare v0.13.2...v0.13.3](https://github.com/dry-rb/dry-types/compare/v0.13.2...v0.13.3)
|
351
488
|
|
352
|
-
|
489
|
+
## 0.13.2 2018-05-30
|
490
|
+
|
353
491
|
|
354
|
-
|
492
|
+
### Fixed
|
355
493
|
|
356
494
|
- `Defaults#valid?` now works fine when passing `Dry::Core::Constans::Undefined` as value (GustavoCaso)
|
357
495
|
- `valid?` for constructor types wrapping `Sum`s (GustavoCaso)
|
358
496
|
|
497
|
+
|
359
498
|
[Compare v0.13.1...v0.13.2](https://github.com/dry-rb/dry-types/compare/v0.13.1...v0.13.2)
|
360
499
|
|
361
|
-
|
500
|
+
## 0.13.1 2018-05-28
|
501
|
+
|
362
502
|
|
363
|
-
|
503
|
+
### Added
|
504
|
+
|
505
|
+
- `params.int` was added to make the upgrade process in dry-validation smoother (available after you `require 'dry/types/compat/int'`) (flash-gordon)
|
506
|
+
|
507
|
+
### Fixed
|
364
508
|
|
365
509
|
- Defaults now works fine with meta (GustavoCaso)
|
366
510
|
- Defaults are now re-decorated properly (flash-gordon)
|
367
511
|
|
368
|
-
## Added
|
369
|
-
|
370
|
-
- `params.int` was added to make the upgrade process in dry-validation smoother (available after you `require 'dry/types/compat/int'`) (flash-gordon)
|
371
512
|
|
372
513
|
[Compare v0.13.0...v0.13.1](https://github.com/dry-rb/dry-types/compare/v0.13.0...v0.13.1)
|
373
514
|
|
374
|
-
|
375
|
-
|
376
|
-
## Changed
|
515
|
+
## 0.13.0 2018-05-03
|
377
516
|
|
378
|
-
- [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)
|
379
|
-
- [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)
|
380
|
-
- [BREAKING] Default types are not evaluated on `nil`. Default values are evaluated _only_ if no value were given.
|
381
|
-
```ruby
|
382
|
-
type = Types::Strict::String.default("hello")
|
383
|
-
type[nil] # => constraint error
|
384
|
-
type[] # => "hello"
|
385
|
-
```
|
386
|
-
This change allowed to greatly simplify hash schemas, make them a lot more flexible yet predictable (see below).
|
387
|
-
- [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)
|
388
|
-
- [BREAKING] Enum types don't accept value index anymore. Instead, explicit mapping is supported, see below (flash-gordon)
|
389
517
|
|
390
|
-
|
518
|
+
### Added
|
391
519
|
|
392
520
|
- 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:
|
393
521
|
|
@@ -425,7 +553,6 @@
|
|
425
553
|
```
|
426
554
|
|
427
555
|
(flash-gordon)
|
428
|
-
|
429
556
|
- `Types.Strict` is an alias for `Types.Instance` (flash-gordon)
|
430
557
|
```ruby
|
431
558
|
strict_range = Types.Strict(Range)
|
@@ -455,175 +582,208 @@
|
|
455
582
|
dict[10] # => 'published'
|
456
583
|
```
|
457
584
|
|
458
|
-
|
585
|
+
### Fixed
|
459
586
|
|
460
587
|
- Fixed applying constraints to optional type, i.e. `.optional.constrained` works correctly (flash-gordon)
|
461
588
|
- Fixed enum working with optionals (flash-gordon)
|
462
|
-
|
463
|
-
## Internal
|
464
|
-
|
589
|
+
- ## Internal
|
465
590
|
- Dropped the `dry-configurable` dependency (GustavoCaso)
|
466
591
|
- The gem now uses `dry-inflector` for inflections instead of `inflecto` (GustavoCaso)
|
467
592
|
|
593
|
+
### Changed
|
594
|
+
|
595
|
+
- [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)
|
596
|
+
- [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)
|
597
|
+
- [BREAKING] Default types are not evaluated on `nil`. Default values are evaluated _only_ if no value were given.
|
598
|
+
```ruby
|
599
|
+
type = Types::Strict::String.default("hello")
|
600
|
+
type[nil] # => constraint error
|
601
|
+
type[] # => "hello"
|
602
|
+
```
|
603
|
+
This change allowed to greatly simplify hash schemas, make them a lot more flexible yet predictable (see below).
|
604
|
+
- [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)
|
605
|
+
- [BREAKING] Enum types don't accept value index anymore. Instead, explicit mapping is supported, see below (flash-gordon)
|
606
|
+
|
468
607
|
[Compare v0.12.2...v0.13.0](https://github.com/dry-rb/dry-types/compare/v0.12.2...v0.13.0)
|
469
608
|
|
470
|
-
|
609
|
+
## 0.12.2 2017-11-04
|
610
|
+
|
471
611
|
|
472
|
-
|
612
|
+
### Fixed
|
473
613
|
|
474
614
|
- The type compiler was fixed for simple rules such as used for strict type checks (flash-gordon)
|
475
615
|
- Fixed an error on `Dry::Types['json.decimal'].try(nil)` (nesaulov)
|
476
616
|
- Fixed an error on calling `try` on an array type built of constrained types (flash-gordon)
|
477
617
|
- Implemented `===` for enum types (GustavoCaso)
|
478
618
|
|
619
|
+
|
479
620
|
[Compare v0.12.1...v0.12.2](https://github.com/dry-rb/dry-types/compare/v0.12.1...v0.12.2)
|
480
621
|
|
481
|
-
|
622
|
+
## 0.12.1 2017-10-11
|
482
623
|
|
483
|
-
|
624
|
+
|
625
|
+
### Fixed
|
484
626
|
|
485
627
|
- `Constructor#try` rescues `ArgumentError` (raised in cases like `Integer('foo')`) (flash-gordon)
|
486
628
|
- `#constructor` works correctly for default and enum types (solnic)
|
487
629
|
- Optional sum types work correctly in `safe` mode (GustavoCaso)
|
488
630
|
- The equalizer of constrained types respects meta (flash-gordon)
|
489
631
|
|
490
|
-
[Compare v0.12.0...v0.12.1](https://github.com/dry-rb/dry-types/compare/v0.12.0...v0.12.1)
|
491
632
|
|
492
|
-
|
633
|
+
[Compare v0.12.0...v0.12.1](https://github.com/dry-rb/dry-types/compare/v0.12.0...v0.12.1)
|
493
634
|
|
494
|
-
##
|
635
|
+
## 0.12.0 2017-09-15
|
495
636
|
|
496
|
-
- A bunch of shortcut methods for constructing types to the autogenerated module, e.g. `Types.Constructor(String, &:to_s)` (flash-gordon)
|
497
637
|
|
498
|
-
|
638
|
+
### Added
|
499
639
|
|
640
|
+
- A bunch of shortcut methods for constructing types to the autogenerated module, e.g. `Types.Constructor(String, &:to_s)` (flash-gordon)
|
641
|
+
- ## Deprecated
|
500
642
|
- `Types::Array#member` was deprecated in favor of `Types::Array#of` (flash-gordon)
|
501
643
|
|
644
|
+
|
502
645
|
[Compare v0.11.1...v0.12.0](https://github.com/dry-rb/dry-types/compare/v0.11.1...v0.12.0)
|
503
646
|
|
504
|
-
|
647
|
+
## 0.11.1 2017-08-14
|
505
648
|
|
506
|
-
## Changed
|
507
649
|
|
508
|
-
|
509
|
-
|
510
|
-
## Fixed
|
650
|
+
### Fixed
|
511
651
|
|
512
652
|
- Fixed `Constructor#name` with `Sum`-types (flash-gordon)
|
513
653
|
|
654
|
+
### Changed
|
655
|
+
|
656
|
+
- Constructors are now equalized using `fn` and `meta` too (flash-gordon)
|
657
|
+
|
514
658
|
[Compare v0.11.0...v0.11.1](https://github.com/dry-rb/dry-types/compare/v0.11.0...v0.11.1)
|
515
659
|
|
516
|
-
|
660
|
+
## 0.11.0 2017-06-30
|
661
|
+
|
517
662
|
|
518
|
-
|
663
|
+
### Added
|
519
664
|
|
520
665
|
- `#to_ast` available for all type objects (GustavoCaso)
|
521
666
|
- `Types::Array#of` as an alias for `#member` (maliqq)
|
522
667
|
- Detailed failure objects are passed to results which improves constraint violation messages (GustavoCaso)
|
523
668
|
|
669
|
+
|
524
670
|
[Compare v0.10.3...v0.11.0](https://github.com/dry-rb/dry-types/compare/v0.10.3...v0.11.0)
|
525
671
|
|
526
|
-
|
672
|
+
## 0.10.3 2017-05-06
|
673
|
+
|
527
674
|
|
528
|
-
|
675
|
+
### Added
|
529
676
|
|
530
677
|
- Callable defaults accept the underlying type (v-kolesnikov)
|
531
678
|
|
679
|
+
|
532
680
|
[Compare v0.10.2...v0.10.3](https://github.com/dry-rb/dry-types/compare/v0.10.2...v0.10.3)
|
533
681
|
|
534
|
-
|
682
|
+
## 0.10.2 2017-04-28
|
683
|
+
|
535
684
|
|
536
|
-
|
685
|
+
### Fixed
|
537
686
|
|
538
687
|
- Fixed `Type#optional?` for sum types (flash-gordon)
|
539
688
|
|
689
|
+
|
540
690
|
[Compare v0.10.1...v0.10.2](https://github.com/dry-rb/dry-types/compare/v0.10.1...v0.10.2)
|
541
691
|
|
542
|
-
|
692
|
+
## 0.10.1 2017-04-28
|
693
|
+
|
543
694
|
|
544
|
-
|
695
|
+
### Added
|
545
696
|
|
546
697
|
- `Type#optional?` returns true if type is Sum and left is nil (GustavoCaso)
|
547
698
|
- `Type#pristine` returns a type without `meta` (flash-gordon)
|
548
699
|
|
549
|
-
|
700
|
+
### Fixed
|
550
701
|
|
551
702
|
- `meta` is used in type equality again (solnic)
|
552
703
|
- `Any` works correctly with meta again (flash-gordon)
|
553
704
|
|
705
|
+
|
554
706
|
[Compare v0.10.0...v0.10.1](https://github.com/dry-rb/dry-types/compare/v0.10.0...v0.10.1)
|
555
707
|
|
556
|
-
|
708
|
+
## 0.10.0 2017-04-26
|
557
709
|
|
558
|
-
|
710
|
+
|
711
|
+
### Added
|
559
712
|
|
560
713
|
- Types can be used in `case` statements now (GustavoCaso)
|
561
714
|
|
562
|
-
|
715
|
+
### Fixed
|
563
716
|
|
564
717
|
- Return original value when Date.parse raises a RangeError (jviney)
|
565
718
|
|
566
|
-
|
719
|
+
### Changed
|
567
720
|
|
568
721
|
- Meta data are now stored separately from options (flash-gordon)
|
569
722
|
- `Types::Object` was renamed to `Types::Any` (flash-gordon)
|
570
723
|
|
571
724
|
[Compare v0.9.4...v0.10.0](https://github.com/dry-rb/dry-types/compare/v0.9.4...v0.10.0)
|
572
725
|
|
573
|
-
|
726
|
+
## 0.9.4 2017-01-24
|
727
|
+
|
574
728
|
|
575
|
-
|
729
|
+
### Added
|
576
730
|
|
577
731
|
- Added `Types::Object` which passes an object of any type (flash-gordon)
|
578
732
|
|
733
|
+
|
579
734
|
[Compare v0.9.3...v0.9.4](https://github.com/dry-rb/dry-types/compare/v0.9.3...v0.9.4)
|
580
735
|
|
581
|
-
|
736
|
+
## 0.9.3 2016-12-03
|
737
|
+
|
582
738
|
|
583
|
-
|
739
|
+
### Fixed
|
584
740
|
|
585
741
|
- Updated to dry-core >= 0.2.1 (ruby warnings are gone) (flash-gordon)
|
586
742
|
|
743
|
+
|
587
744
|
[Compare v0.9.2...v0.9.3](https://github.com/dry-rb/dry-types/compare/v0.9.2...v0.9.3)
|
588
745
|
|
589
|
-
|
746
|
+
## 0.9.2 2016-11-13
|
590
747
|
|
591
|
-
|
748
|
+
|
749
|
+
### Added
|
592
750
|
|
593
751
|
- Support for `"Y"` and `"N"` as `true` and `false` values, respectively (scare21410)
|
594
752
|
|
595
|
-
|
753
|
+
### Changed
|
596
754
|
|
597
755
|
- Optimized object allocation in hash schemas, resulting in up to 25% speed boost (davydovanton)
|
598
756
|
|
599
757
|
[Compare v0.9.1...v0.9.2](https://github.com/dry-rb/dry-types/compare/v0.9.1...v0.9.2)
|
600
758
|
|
601
|
-
|
759
|
+
## 0.9.1 2016-11-04
|
760
|
+
|
602
761
|
|
603
|
-
|
762
|
+
### Fixed
|
604
763
|
|
605
764
|
- `Hash#strict_with_defaults` properly evaluates callable defaults (bolshakov)
|
606
765
|
|
607
|
-
|
766
|
+
### Changed
|
608
767
|
|
609
768
|
- `Hash#weak` accepts Hash-descendants again (solnic)
|
610
769
|
|
611
770
|
[Compare v0.9.0...v0.9.1](https://github.com/dry-rb/dry-types/compare/v0.9.0...v0.9.1)
|
612
771
|
|
613
|
-
|
772
|
+
## 0.9.0 2016-09-21
|
614
773
|
|
615
|
-
|
774
|
+
|
775
|
+
### Added
|
616
776
|
|
617
777
|
- `Hash#strict_with_defaults` which validates presence of all required keys and respects default types for missing _values_ (backus)
|
618
778
|
- `Type#constrained?` method (flash-gordon)
|
619
779
|
|
620
|
-
|
780
|
+
### Fixed
|
621
781
|
|
622
782
|
- Summing two constrained types works correctly (flash-gordon)
|
623
783
|
- `Types::Array::Member#valid?` in cases where member type is a constraint (solnic)
|
624
784
|
- `Hash::Schema#try` handles exceptions properly and returns a failure object (solnic)
|
625
785
|
|
626
|
-
|
786
|
+
### Changed
|
627
787
|
|
628
788
|
- [BREAKING] Renamed `Hash##{schema=>permissive}` (backus)
|
629
789
|
- [BREAKING] `dry-monads` dependency was made optional, Maybe types are available after `Dry::Types.load_extensions(:maybe)` (flash-gordon)
|
@@ -634,43 +794,47 @@
|
|
634
794
|
|
635
795
|
[Compare v0.8.1...v0.9.0](https://github.com/dry-rb/dry-types/compare/v0.8.1...v0.9.0)
|
636
796
|
|
637
|
-
|
797
|
+
## 0.8.1 2016-07-13
|
798
|
+
|
638
799
|
|
639
|
-
|
800
|
+
### Fixed
|
640
801
|
|
641
802
|
- Compiler no longer chokes on type nodes without args (solnic)
|
642
803
|
- Removed `bin/console` from gem package (solnic)
|
643
804
|
|
805
|
+
|
644
806
|
[Compare v0.8.0...v0.8.1](https://github.com/dry-rb/dry-types/compare/v0.8.0...v0.8.1)
|
645
807
|
|
646
|
-
|
808
|
+
## 0.8.0 2016-07-01
|
647
809
|
|
648
|
-
|
810
|
+
|
811
|
+
### Added
|
649
812
|
|
650
813
|
- `Struct` now implements `Type` interface so ie `SomeStruct | String` works now (flash-gordon)
|
651
814
|
- `:weak` Hash constructor which can partially coerce a hash even when it includes invalid values (solnic)
|
652
815
|
- Types include `Dry::Equalizer` now (flash-gordon)
|
653
816
|
|
654
|
-
|
817
|
+
### Fixed
|
655
818
|
|
656
819
|
- `Struct#to_hash` descends into arrays too (nepalez)
|
657
820
|
- `Default#with` works now (flash-gordon)
|
658
821
|
|
659
|
-
|
822
|
+
### Changed
|
660
823
|
|
661
824
|
- `:symbolized` hash schema is now based on `:weak` schema (solnic)
|
662
825
|
- `Struct::Value` instances are now **deeply frozen** via ice_nine (backus)
|
663
826
|
|
664
827
|
[Compare v0.7.2...v0.8.0](https://github.com/dry-rb/dry-types/compare/v0.7.2...v0.8.0)
|
665
828
|
|
666
|
-
|
829
|
+
## 0.7.2 2016-05-11
|
830
|
+
|
667
831
|
|
668
|
-
|
832
|
+
### Fixed
|
669
833
|
|
670
834
|
- `Bool#default` gladly accepts `false` as its value (solnic)
|
671
835
|
- Creating an empty schema with input processor no longer fails (lasseebert)
|
672
836
|
|
673
|
-
|
837
|
+
### Changed
|
674
838
|
|
675
839
|
- Allow multiple calls to meta (solnic)
|
676
840
|
- Allow capitalised versions of true and false values for boolean coercions (nil0bject)
|
@@ -682,24 +846,26 @@
|
|
682
846
|
|
683
847
|
[Compare v0.7.1...v0.7.2](https://github.com/dry-rb/dry-types/compare/v0.7.1...v0.7.2)
|
684
848
|
|
685
|
-
|
849
|
+
## 0.7.1 2016-04-06
|
686
850
|
|
687
|
-
|
851
|
+
|
852
|
+
### Added
|
688
853
|
|
689
854
|
- `JSON::*` types with JSON-specific coercions (coop)
|
690
855
|
|
691
|
-
|
856
|
+
### Fixed
|
692
857
|
|
693
858
|
- Schema is properly inherited in Struct (backus)
|
694
859
|
- `constructor_type` is properly inherited in Struct (fbernier)
|
695
860
|
|
861
|
+
|
696
862
|
[Compare v0.7.0...v0.7.1](https://github.com/dry-rb/dry-types/compare/v0.7.0...v0.7.1)
|
697
863
|
|
698
|
-
|
864
|
+
## 0.7.0 2016-03-30
|
699
865
|
|
700
866
|
Major focus of this release is to make complex type composition possible and improving constraint errors to be more meaningful.
|
701
867
|
|
702
|
-
|
868
|
+
### Added
|
703
869
|
|
704
870
|
- `Type#try` interface that tries to process the input and return a result object which can be either a success or failure (solnic)
|
705
871
|
- `#meta` interface for setting arbitrary meta data on types (solnic)
|
@@ -709,12 +875,12 @@ Major focus of this release is to make complex type composition possible and imp
|
|
709
875
|
- Compiler supports `[:constructor, [primitive, fn_proc]]` nodes (solnic)
|
710
876
|
- Compiler supports building schema-less `form.hash` types (solnic)
|
711
877
|
|
712
|
-
|
878
|
+
### Fixed
|
713
879
|
|
714
880
|
- `Sum` now supports complex types like `Array` or `Hash` with member types and/or constraints (solnic)
|
715
881
|
- `Default#constrained` will properly wrap a new constrained type (solnic)
|
716
882
|
|
717
|
-
|
883
|
+
### Changed
|
718
884
|
|
719
885
|
- [BREAKING] Renamed `Type#{optional=>maybe}` (AMHOL)
|
720
886
|
- [BREAKING] `Type#optional(other)` builds a sum: `Strict::Nil | other` (AMHOL)
|
@@ -729,11 +895,11 @@ Major focus of this release is to make complex type composition possible and imp
|
|
729
895
|
|
730
896
|
[Compare v0.6.0...v0.7.0](https://github.com/dry-rb/dry-types/compare/v0.6.0...v0.7.0)
|
731
897
|
|
732
|
-
|
898
|
+
## 0.6.0 2016-03-16
|
733
899
|
|
734
900
|
Renamed from `dry-data` to `dry-types` and:
|
735
901
|
|
736
|
-
|
902
|
+
### Added
|
737
903
|
|
738
904
|
- `Dry::Types.module` which returns a namespace for inclusion which has all
|
739
905
|
built-in types defined as constants (solnic)
|
@@ -745,7 +911,7 @@ Renamed from `dry-data` to `dry-types` and:
|
|
745
911
|
- `Types.register_class` accepts a second arg which is the name of the class'
|
746
912
|
constructor method, defaults to `:new` (solnic)
|
747
913
|
|
748
|
-
|
914
|
+
### Fixed
|
749
915
|
|
750
916
|
- `Struct` will simply pass-through the input if it is already a struct (solnic)
|
751
917
|
- `default` will raise if a value violates constraints (solnic)
|
@@ -757,30 +923,37 @@ Renamed from `dry-data` to `dry-types` and:
|
|
757
923
|
no single primitive for an optional value (solnic)
|
758
924
|
- `Optional` passes-through a value which is already a maybe (solnic)
|
759
925
|
|
760
|
-
|
926
|
+
### Changed
|
761
927
|
|
762
928
|
- `Dry::Types::Definition` is now the base type definition object (solnic)
|
763
929
|
- `Dry::Types::Constructor` is now a type definition with a constructor function (solnic)
|
764
930
|
|
765
931
|
[Compare v0.5.1...v0.6.0](https://github.com/dry-rb/dry-types/compare/v0.5.1...v0.6.0)
|
766
932
|
|
767
|
-
|
933
|
+
## 0.5.1 2016-01-11
|
768
934
|
|
769
|
-
|
935
|
+
|
936
|
+
### Added
|
770
937
|
|
771
938
|
- `Dry::Data::Type#safe` for types which can skip constructor when primitive does
|
772
939
|
not match input's class (solnic)
|
773
940
|
- `form.array` and `form.hash` safe types (solnic)
|
774
941
|
|
942
|
+
|
775
943
|
[Compare v0.5.0...v0.5.1](https://github.com/dry-rb/dry-types/compare/v0.5.0...v0.5.1)
|
776
944
|
|
777
|
-
|
945
|
+
## 0.5.0 2016-01-11
|
778
946
|
|
779
|
-
|
947
|
+
|
948
|
+
### Added
|
780
949
|
|
781
950
|
- `Type#default` interface for defining a type with a default value (solnic)
|
782
951
|
|
783
|
-
|
952
|
+
### Fixed
|
953
|
+
|
954
|
+
- `attribute` raises proper error when type definition is missing (solnic)
|
955
|
+
|
956
|
+
### Changed
|
784
957
|
|
785
958
|
- [BREAKING] `Dry::Data::Type.new` accepts constructor and _options_ now (solnic)
|
786
959
|
- Renamed `Dry::Data::Type::{Enum,Constrained}` => `Dry::Data::{Enum,Constrained}` (solnic)
|
@@ -789,60 +962,62 @@ Renamed from `dry-data` to `dry-types` and:
|
|
789
962
|
- `strict.*` category uses constrained types with `:type?` predicate (solnic)
|
790
963
|
- `SumType#call` no longer needs to rescue from `TypeError` (solnic)
|
791
964
|
|
792
|
-
## Fixed
|
793
|
-
|
794
|
-
- `attribute` raises proper error when type definition is missing (solnic)
|
795
|
-
|
796
965
|
[Compare v0.4.2...v0.5.0](https://github.com/dry-rb/dry-types/compare/v0.4.2...v0.5.0)
|
797
966
|
|
798
|
-
|
967
|
+
## 0.4.2 2015-12-27
|
799
968
|
|
800
|
-
|
969
|
+
|
970
|
+
### Added
|
801
971
|
|
802
972
|
- Support for arrays in type compiler (solnic)
|
803
973
|
|
804
|
-
|
974
|
+
### Changed
|
805
975
|
|
806
976
|
- Array member uses type objects now rather than just their constructors (solnic)
|
807
977
|
|
808
|
-
[Compare v0.4.
|
978
|
+
[Compare v0.4.0...v0.4.2](https://github.com/dry-rb/dry-types/compare/v0.4.0...v0.4.2)
|
979
|
+
|
980
|
+
## 0.4.0 2015-12-11
|
809
981
|
|
810
|
-
# v0.4.0 2015-12-11
|
811
982
|
|
812
|
-
|
983
|
+
### Added
|
813
984
|
|
814
985
|
- Support for sum-types with constraint type (solnic)
|
815
986
|
- `Dry::Data::Type#optional` for defining optional types (solnic)
|
816
987
|
|
817
|
-
|
988
|
+
### Changed
|
818
989
|
|
819
990
|
- `Dry::Data['optional']` was **removed** in favor of `Dry::Data::Type#optional` (solnic)
|
820
991
|
|
821
992
|
[Compare v0.3.2...v0.4.0](https://github.com/dry-rb/dry-types/compare/v0.3.2...v0.4.0)
|
822
993
|
|
823
|
-
|
994
|
+
## 0.3.2 2015-12-10
|
824
995
|
|
825
|
-
|
996
|
+
|
997
|
+
### Added
|
826
998
|
|
827
999
|
- `Dry::Data::Value` which works like a struct but is a value object with equalizer (solnic)
|
828
1000
|
|
829
|
-
|
1001
|
+
### Fixed
|
830
1002
|
|
831
1003
|
- Added missing require for `dry-equalizer` (solnic)
|
832
1004
|
|
1005
|
+
|
833
1006
|
[Compare v0.3.1...v0.3.2](https://github.com/dry-rb/dry-types/compare/v0.3.1...v0.3.2)
|
834
1007
|
|
835
|
-
|
1008
|
+
## 0.3.1 2015-12-09
|
1009
|
+
|
836
1010
|
|
837
|
-
|
1011
|
+
### Changed
|
838
1012
|
|
839
1013
|
- Removed require of constrained type and make it optional (solnic)
|
840
1014
|
|
841
1015
|
[Compare v0.3.0...v0.3.1](https://github.com/dry-rb/dry-types/compare/v0.3.0...v0.3.1)
|
842
1016
|
|
843
|
-
|
1017
|
+
## 0.3.0 2015-12-09
|
844
1018
|
|
845
|
-
|
1019
|
+
|
1020
|
+
### Added
|
846
1021
|
|
847
1022
|
- `Type#constrained` interface for defining constrained types (solnic)
|
848
1023
|
- `Dry::Data` can be configured with a type namespace (solnic)
|
@@ -850,41 +1025,45 @@ Renamed from `dry-data` to `dry-types` and:
|
|
850
1025
|
- `Dry::Data::Type#enum` for defining an enum from a specific type (solnic)
|
851
1026
|
- New types: `symbol` and `class` along with their `strict` versions (solnic)
|
852
1027
|
|
1028
|
+
|
853
1029
|
[Compare v0.2.1...v0.3.0](https://github.com/dry-rb/dry-types/compare/v0.2.1...v0.3.0)
|
854
1030
|
|
855
|
-
|
1031
|
+
## 0.2.1 2015-11-30
|
856
1032
|
|
857
|
-
|
1033
|
+
|
1034
|
+
### Added
|
858
1035
|
|
859
1036
|
- Type compiler supports nested hashes now (solnic)
|
860
1037
|
|
861
|
-
|
1038
|
+
### Fixed
|
862
1039
|
|
863
1040
|
- `form.bool` sum is using correct right-side `form.false` type (solnic)
|
864
1041
|
|
865
|
-
|
1042
|
+
### Changed
|
866
1043
|
|
867
1044
|
- Improved structure of the ast (solnic)
|
868
1045
|
|
869
1046
|
[Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-types/compare/v0.2.0...v0.2.1)
|
870
1047
|
|
871
|
-
|
1048
|
+
## 0.2.0 2015-11-29
|
1049
|
+
|
872
1050
|
|
873
|
-
|
1051
|
+
### Added
|
874
1052
|
|
875
1053
|
- `form.nil` which coerces empty strings to `nil` (solnic)
|
876
1054
|
- `bool` sum-type (true | false) (solnic)
|
877
1055
|
- Type compiler supports sum-types now (solnic)
|
878
1056
|
|
879
|
-
|
1057
|
+
### Changed
|
880
1058
|
|
881
1059
|
- Constructing optional types uses the new `Dry::Data["optional"]` built-in type (solnic)
|
882
1060
|
|
883
1061
|
[Compare v0.1.0...v0.2.0](https://github.com/dry-rb/dry-types/compare/v0.1.0...v0.2.0)
|
884
1062
|
|
885
|
-
|
1063
|
+
## 0.1.0 2015-11-27
|
886
1064
|
|
887
|
-
|
1065
|
+
|
1066
|
+
### Added
|
888
1067
|
|
889
1068
|
- `form.*` coercible types (solnic)
|
890
1069
|
- `Type::Hash#strict` for defining hashes with a strict schema (solnic)
|
@@ -893,8 +1072,9 @@ Renamed from `dry-data` to `dry-types` and:
|
|
893
1072
|
setting its `.new` method as the constructor (solnic)
|
894
1073
|
- `Dry::Data::Compiler` for building a type from a simple ast (solnic)
|
895
1074
|
|
896
|
-
[Compare v0.0.1...HEAD](https://github.com/dry-rb/dry-types/compare/v0.0.1...HEAD)
|
897
1075
|
|
898
|
-
|
1076
|
+
[Compare v0.0.1...v0.1.0](https://github.com/dry-rb/dry-types/compare/v0.0.1...v0.1.0)
|
1077
|
+
|
1078
|
+
## 0.0.1 2015-10-05
|
899
1079
|
|
900
1080
|
First public release
|