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