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