dry-types 0.9.0 → 0.15.0

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 (61) hide show
  1. checksums.yaml +5 -5
  2. data/.codeclimate.yml +15 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +43 -0
  5. data/.travis.yml +15 -14
  6. data/.yardopts +5 -0
  7. data/CHANGELOG.md +494 -88
  8. data/CONTRIBUTING.md +29 -0
  9. data/Gemfile +7 -6
  10. data/README.md +1 -3
  11. data/Rakefile +8 -3
  12. data/benchmarks/hash_schemas.rb +7 -7
  13. data/dry-types.gemspec +11 -9
  14. data/lib/dry/types/any.rb +36 -0
  15. data/lib/dry/types/array/member.rb +29 -4
  16. data/lib/dry/types/array.rb +6 -4
  17. data/lib/dry/types/builder.rb +48 -6
  18. data/lib/dry/types/builder_methods.rb +111 -0
  19. data/lib/dry/types/coercions/json.rb +3 -0
  20. data/lib/dry/types/coercions/{form.rb → params.rb} +23 -3
  21. data/lib/dry/types/coercions.rb +16 -3
  22. data/lib/dry/types/compat.rb +0 -0
  23. data/lib/dry/types/compiler.rb +66 -39
  24. data/lib/dry/types/constrained/coercible.rb +7 -1
  25. data/lib/dry/types/constrained.rb +42 -3
  26. data/lib/dry/types/constraints.rb +3 -0
  27. data/lib/dry/types/constructor.rb +98 -16
  28. data/lib/dry/types/container.rb +2 -0
  29. data/lib/dry/types/core.rb +30 -14
  30. data/lib/dry/types/decorator.rb +31 -5
  31. data/lib/dry/types/default.rb +34 -8
  32. data/lib/dry/types/enum.rb +71 -14
  33. data/lib/dry/types/errors.rb +23 -6
  34. data/lib/dry/types/extensions/maybe.rb +35 -16
  35. data/lib/dry/types/fn_container.rb +34 -0
  36. data/lib/dry/types/hash/constructor.rb +20 -0
  37. data/lib/dry/types/hash.rb +103 -23
  38. data/lib/dry/types/inflector.rb +7 -0
  39. data/lib/dry/types/json.rb +7 -7
  40. data/lib/dry/types/map.rb +98 -0
  41. data/lib/dry/types/module.rb +115 -0
  42. data/lib/dry/types/nominal.rb +119 -0
  43. data/lib/dry/types/options.rb +29 -7
  44. data/lib/dry/types/params.rb +53 -0
  45. data/lib/dry/types/printable.rb +12 -0
  46. data/lib/dry/types/printer.rb +309 -0
  47. data/lib/dry/types/result.rb +12 -2
  48. data/lib/dry/types/safe.rb +27 -1
  49. data/lib/dry/types/schema/key.rb +130 -0
  50. data/lib/dry/types/schema.rb +298 -0
  51. data/lib/dry/types/spec/types.rb +102 -0
  52. data/lib/dry/types/sum.rb +75 -13
  53. data/lib/dry/types/type.rb +6 -0
  54. data/lib/dry/types/version.rb +1 -1
  55. data/lib/dry/types.rb +104 -38
  56. data/log/.gitkeep +0 -0
  57. metadata +81 -50
  58. data/lib/dry/types/definition.rb +0 -79
  59. data/lib/dry/types/form.rb +0 -53
  60. data/lib/dry/types/hash/schema.rb +0 -156
  61. data/lib/spec/dry/types.rb +0 -56
data/CHANGELOG.md CHANGED
@@ -1,55 +1,461 @@
1
+ # 0.15.0 2019-03-22
2
+
3
+ ## Changed
4
+
5
+ - [BREAKING] Internal representation of hash schemas was changed to be a simple list of key types (flash-gordon)
6
+ `Dry::Types::Hash#with_type_transform` now yields a key type instead of type + name:
7
+ ```ruby
8
+ Dry::Types['strict.hash'].with_type_transform { |key| key.name == :age ? key.required(false) : key }
9
+ ```
10
+ - [BREAKING] Definition types were renamed to nominal (flash-gordon)
11
+ - [BREAKING] Top-level types returned by `Dry::Types.[]` are now strict (flash-gordon)
12
+ ```ruby
13
+ # before
14
+ Dry::Types['integer']
15
+ # => #<Dry::Types[Nominal<Integer>]>
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>]>
22
+ ```
23
+ - [BREAKING] Default values are not evaluated if the decorated type returns `nil`. They are triggered on `Undefined` instead (GustavoCaso + flash-gordon)
24
+ - [BREAKING] Support for old hash schemas was fully removed. This makes dry-types not compatible with dry-validation < 1.0 (flash-gordon)
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
27
+ ```ruby
28
+ module Types
29
+ include Dry.Types
30
+ end
31
+ ```
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
+
36
+ ## Added
37
+
38
+ - Improved string representation of types (flash-gordon)
39
+ ```ruby
40
+ Dry::Types['nominal.integer']
41
+ # => #<Dry::Types[Nominal<Integer>]>
42
+ Dry::Types['params.integer']
43
+ # => #<Dry::Types[Constructor<Nominal<Integer> fn=Dry::Types::Coercions::Params.to_int>]>
44
+ Dry::Types['hash'].schema(age?: 'integer')
45
+ # => #<Dry::Types[Constrained<Schema<keys={age?: Constrained<Nominal<Integer> rule=[type?(Integer)]>}> rule=[type?(Hash)]>]>
46
+ Dry::Types['array<integer>']
47
+ # => #<Dry::Types[Constrained<Array<Constrained<Nominal<Integer> rule=[type?(Integer)]>> rule=[type?(Array)]>]>
48
+ ```
49
+ - Options for the list of types you want to import with `Dry.Types` (flash-gordon)
50
+ Cherry-pick only certain types:
51
+ ```ruby
52
+ module Types
53
+ include Dry.Types(:strict, :nominal, :coercible)
54
+ end
55
+ Types.constants
56
+ # => [:Strict, :Nominal, :Coercible]
57
+ ```
58
+ Change default top-level types:
59
+ ```ruby
60
+ module Types
61
+ include Dry.Types(default: :coercible)
62
+ end
63
+ # => #<Dry::Types[Constructor<Nominal<Integer> fn=Kernel.Integer>]>
64
+ ```
65
+ Rename type namespaces:
66
+ ```ruby
67
+ module Types
68
+ include Dry.Types(strict: :Strong, coercible: :Kernel)
69
+ end
70
+ ```
71
+ - Optional keys for schemas can be provided with ?-ending symbols (flash-gordon)
72
+ ```ruby
73
+ Dry::Types['hash'].schema(name: 'string', age?: 'integer')
74
+ ```
75
+ - Another way of making keys optional is setting `required: false` to meta. In fact, it is the preferable
76
+ way if you have to store this information in `meta`, otherwise use the Key's API (see below) (flash-gordon)
77
+ ```ruby
78
+ Dry::Types['hash'].schema(
79
+ name: Dry::Types['string'],
80
+ age: Dry::Types['integer'].meta(required: false)
81
+ )
82
+ ```
83
+ - Key types have API for making keys omittable and back (flash-gordon)
84
+ ```ruby
85
+ # defining a base schema with optional keys
86
+ lax_hash = Dry::Types['hash'].with_type_transform { |key| key.required(false) }
87
+ # same as
88
+ lax_hash = Dry::Types['hash'].with_type_transform(&:omittable)
89
+
90
+ # keys in user_schema are not required
91
+ user_schema = lax_hash.schema(name: 'string', age: 'integer')
92
+ ```
93
+ - `Type#optional?` now recognizes more cases where `nil` is an allowed value (flash-gordon)
94
+ - `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)
95
+ ```ruby
96
+ to_int = Types::Coercible::Integer
97
+ inc = to_int.append { |x| x + 2 }
98
+ inc.("1") # => "1" -> 1 -> 3
99
+
100
+ inc = to_int.prepend { |x| x + "2" }
101
+ inc.("1") # => "1" -> "12" -> 12
102
+ ```
103
+ - Partial schema application for cases when you want to validate only a subset of keys (flash-gordon)
104
+ 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.
105
+ ```ruby
106
+ schema = Dry::Types['hash'].schema(name: 'string', age: 'integer')
107
+ value = schema.(name: 'John', age: 20)
108
+ update = schema.apply({ age: 21 }, skip_missing: true)
109
+ value.merge(update)
110
+ ```
111
+
112
+ ## Fixed
113
+
114
+ * `Hash::Map` now behaves as a constrained type if its values are constrained (flash-gordon)
115
+ * `coercible.integer` now doesn't blow up on invalid strings (exterm)
116
+
117
+ [Compare v0.14.0...v0.15.0](https://github.com/dry-rb/dry-types/compare/v0.14.0...v0.15.0)
118
+
119
+ # 0.14.0 2019-01-29
120
+
121
+ ## Changed
122
+
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
+
126
+ ## Fixed
127
+
128
+ - `valid?` works correctly with constructors now (cgeorgii)
129
+
130
+ [Compare v0.13.4...v0.14.0](https://github.com/dry-rb/dry-types/compare/v0.13.4...v0.14.0)
131
+
132
+ # v0.13.4 2018-12-21
133
+
134
+ ## Fixed
135
+
136
+ - Fixed warnings about keyword arguments from Ruby 2.6. See https://bugs.ruby-lang.org/issues/14183 for all the details (flash-gordon)
137
+
138
+ # v0.13.3 2018-11-25
139
+
140
+ ## Fixed
141
+
142
+ - `Dry::Types::Hash#try` returns `Failure` instead of throwing an exception on missing keys (GustavoCaso)
143
+
144
+ [Compare v0.13.2...v0.13.3](https://github.com/dry-rb/dry-types/compare/v0.13.2...v0.13.3)
145
+
146
+ # v0.13.2 2018-05-30
147
+
148
+ ## Fixed
149
+
150
+ - `Defaults#valid?` now works fine when passing `Dry::Core::Constans::Undefined` as value (GustavoCaso)
151
+ - `valid?` for constructor types wrapping `Sum`s (GustavoCaso)
152
+
153
+ [Compare v0.13.1...v0.13.2](https://github.com/dry-rb/dry-types/compare/v0.13.1...v0.13.2)
154
+
155
+ # v0.13.1 2018-05-28
156
+
157
+ ## Fixed
158
+
159
+ - Defaults now works fine with meta (GustavoCaso)
160
+ - Defaults are now re-decorated properly (flash-gordon)
161
+
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
+
166
+ [Compare v0.13.0...v0.13.1](https://github.com/dry-rb/dry-types/compare/v0.13.0...v0.13.1)
167
+
168
+ # v0.13.0 2018-05-03
169
+
170
+ ## Changed
171
+
172
+ - [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)
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
185
+
186
+ - 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
+
188
+ 1. `Schema#with_key_transform`—transforms keys of input hashes, for things like symbolizing etc.
189
+ 2. `Schema#strict`—makes a schema intolerant to unknown keys.
190
+ 3. `Hash#with_type_transform`—transforms member types with an arbitrary block. For instance,
191
+
192
+ ```ruby
193
+ optional_keys = Types::Hash.with_type_transform { |t, _key| t.optional }
194
+ schema = optional_keys.schema(name: 'strict.string', age: 'strict.int')
195
+ schema.(name: "Jane", age: nil) # => {name: "Jane", age: nil}
196
+ ```
197
+
198
+ Note that by default all keys are required, if a key is expected to be absent, add to the corresponding type's meta `omittable: true`:
199
+
200
+ ```ruby
201
+ intolerant = Types::Hash.schema(name: Types::Strict::String)
202
+ intolerant[{}] # => Dry::Types::MissingKeyError
203
+ tolerant = Types::Hash.schema(name: Types::Strict::String.meta(omittable: true))
204
+ tolerant[{}] # => {}
205
+ tolerant_with_default = Types::Hash.schema(name: Types::Strict::String.meta(omittable: true).default("John"))
206
+ tolerant[{}] # => {name: "John"}
207
+ ```
208
+
209
+ The new API is composable in a natural way:
210
+
211
+ ```ruby
212
+ TOLERANT = Types::Hash.with_type_transform { |t| t.meta(omittable: true) }.freeze
213
+ user = TOLERANT.schema(name: 'strict.string', age: 'strict.int')
214
+ user.(name: "Jane") # => {name: "Jane"}
215
+
216
+ TOLERANT_SYMBOLIZED = TOLERANT.with_key_transform(&:to_sym)
217
+ user_sym = TOLERANT_SYMBOLIZED.schema(name: 'strict.string', age: 'strict.int')
218
+ user_sym.("name" => "Jane") # => {name: "Jane"}
219
+ ```
220
+
221
+ (flash-gordon)
222
+
223
+ - `Types.Strict` is an alias for `Types.Instance` (flash-gordon)
224
+ ```ruby
225
+ strict_range = Types.Strict(Range)
226
+ strict_range == Types.Instance(Range) # => true
227
+ ```
228
+ - `Enum#include?` is an alias to `Enum#valid?` (d-Pixie + flash-gordon)
229
+ - `Range` was added (GustavoCaso)
230
+ - `Array` types filter out `Undefined` values, if you have an array type with a constructor type as its member, the constructor now can return `Dry::Types::Undefined` to indicate empty value:
231
+ ```ruby
232
+ filter_empty_strings = Types::Strict::Array.of(
233
+ Types::Strict::String.constructor { |input|
234
+ input.to_s.yield_self { |s| s.empty? ? Dry::Types::Undefined : s }
235
+ }
236
+ )
237
+ filter_empty_strings.(["John", nil, "", "Jane"]) # => ["John", "Jane"]
238
+ ```
239
+ - `Types::Map` was added for homogeneous hashes, when only types of keys and values are known in advance, not specific key names (fledman + flash-gordon)
240
+ ```ruby
241
+ int_to_string = Types::Hash.map('strict.integer', 'strict.string')
242
+ int_to_string[0 => 'foo'] # => { 0 => "foo" }
243
+ int_to_string[0 => 1] # Dry::Types::MapError: input value 1 for key 0 is invalid: type?(String, 1)
244
+ ```
245
+ - Enum supports mappings (bolshakov + flash-gordon)
246
+ ```ruby
247
+ dict = Types::Strict::String.enum('draft' => 0, 'published' => 10, 'archived' => 20)
248
+ dict['published'] # => 'published'
249
+ dict[10] # => 'published'
250
+ ```
251
+
252
+ ## Fixed
253
+
254
+ - Fixed applying constraints to optional type, i.e. `.optional.constrained` works correctly (flash-gordon)
255
+ - Fixed enum working with optionals (flash-gordon)
256
+
257
+ ## Internal
258
+
259
+ - Dropped the `dry-configurable` dependency (GustavoCaso)
260
+ - The gem now uses `dry-inflector` for inflections instead of `inflecto` (GustavoCaso)
261
+
262
+ [Compare v0.12.2...v0.13.0](https://github.com/dry-rb/dry-types/compare/v0.12.2...v0.13.0)
263
+
264
+ # v0.12.2 2017-11-04
265
+
266
+ ## Fixed
267
+
268
+ - The type compiler was fixed for simple rules such as used for strict type checks (flash-gordon)
269
+ - Fixed an error on `Dry::Types['json.decimal'].try(nil)` (nesaulov)
270
+ - Fixed an error on calling `try` on an array type built of constrained types (flash-gordon)
271
+ - Implemented `===` for enum types (GustavoCaso)
272
+
273
+ [Compare v0.12.1...v0.12.2](https://github.com/dry-rb/dry-types/compare/v0.12.1...v0.12.2)
274
+
275
+ # v0.12.1 2017-10-11
276
+
277
+ ## Fixed
278
+
279
+ - `Constructor#try` rescues `ArgumentError` (raised in cases like `Integer('foo')`) (flash-gordon)
280
+ - `#constructor` works correctly for default and enum types (solnic)
281
+ - Optional sum types work correctly in `safe` mode (GustavoCaso)
282
+ - The equalizer of constrained types respects meta (flash-gordon)
283
+
284
+ [Compare v0.12.0...v0.12.1](https://github.com/dry-rb/dry-types/compare/v0.12.0...v0.12.1)
285
+
286
+ # v0.12.0 2017-09-15
287
+
288
+ ## Added
289
+
290
+ - A bunch of shortcut methods for constructing types to the autogenerated module, e.g. `Types.Constructor(String, &:to_s)` (flash-gordon)
291
+
292
+ ## Deprecated
293
+
294
+ - `Types::Array#member` was deprecated in favor of `Types::Array#of` (flash-gordon)
295
+
296
+ [Compare v0.11.1...v0.12.0](https://github.com/dry-rb/dry-types/compare/v0.11.1...v0.12.0)
297
+
298
+ # v0.11.1 2017-08-14
299
+
300
+ ## Changed
301
+
302
+ - Constructors are now equalized using `fn` and `meta` too (flash-gordon)
303
+
304
+ ## Fixed
305
+
306
+ - Fixed `Constructor#name` with `Sum`-types (flash-gordon)
307
+
308
+ [Compare v0.11.0...v0.11.1](https://github.com/dry-rb/dry-types/compare/v0.11.0...v0.11.1)
309
+
310
+ # v0.11.0 2017-06-30
311
+
312
+ ## Added
313
+
314
+ - `#to_ast` available for all type objects (GustavoCaso)
315
+ - `Types::Array#of` as an alias for `#member` (maliqq)
316
+ - Detailed failure objects are passed to results which improves constraint violation messages (GustavoCaso)
317
+
318
+ [Compare v0.10.3...v0.11.0](https://github.com/dry-rb/dry-types/compare/v0.10.3...v0.11.0)
319
+
320
+ # v0.10.3 2017-05-06
321
+
322
+ ## Added
323
+
324
+ - Callable defaults accept the underlying type (v-kolesnikov)
325
+
326
+ [Compare v0.10.2...v0.10.3](https://github.com/dry-rb/dry-types/compare/v0.10.2...v0.10.3)
327
+
328
+ # v0.10.2 2017-04-28
329
+
330
+ ## Fixed
331
+
332
+ - Fixed `Type#optional?` for sum types (flash-gordon)
333
+
334
+ [Compare v0.10.1...v0.10.2](https://github.com/dry-rb/dry-types/compare/v0.10.1...v0.10.2)
335
+
336
+ # v0.10.1 2017-04-28
337
+
338
+ ## Added
339
+
340
+ - `Type#optional?` returns true if type is Sum and left is nil (GustavoCaso)
341
+ - `Type#pristine` returns a type without `meta` (flash-gordon)
342
+
343
+ ## Fixed
344
+
345
+ - `meta` is used in type equality again (solnic)
346
+ - `Any` works correctly with meta again (flash-gordon)
347
+
348
+ [Compare v0.10.0...v0.10.1](https://github.com/dry-rb/dry-types/compare/v0.10.0...v0.10.1)
349
+
350
+ # v0.10.0 2017-04-26
351
+
352
+ ## Added
353
+
354
+ - Types can be used in `case` statements now (GustavoCaso)
355
+
356
+ ## Fixed
357
+
358
+ - Return original value when Date.parse raises a RangeError (jviney)
359
+
360
+ ## Changed
361
+
362
+ - Meta data are now stored separately from options (flash-gordon)
363
+ - `Types::Object` was renamed to `Types::Any` (flash-gordon)
364
+
365
+ [Compare v0.9.4...v0.10.0](https://github.com/dry-rb/dry-types/compare/v0.9.4...v0.10.0)
366
+
367
+ # v0.9.4 2017-01-24
368
+
369
+ ## Added
370
+
371
+ - Added `Types::Object` which passes an object of any type (flash-gordon)
372
+
373
+ [Compare v0.9.3...v0.9.4](https://github.com/dry-rb/dry-types/compare/v0.9.3...v0.9.4)
374
+
375
+ # v0.9.3 2016-12-03
376
+
377
+ ## Fixed
378
+
379
+ - Updated to dry-core >= 0.2.1 (ruby warnings are gone) (flash-gordon)
380
+
381
+ [Compare v0.9.2...v0.9.3](https://github.com/dry-rb/dry-types/compare/v0.9.2...v0.9.3)
382
+
383
+ # v0.9.2 2016-11-13
384
+
385
+ ## Added
386
+
387
+ - Support for `"Y"` and `"N"` as `true` and `false` values, respectively (scare21410)
388
+
389
+ ## Changed
390
+
391
+ - Optimized object allocation in hash schemas, resulting in up to 25% speed boost (davydovanton)
392
+
393
+ [Compare v0.9.1...v0.9.2](https://github.com/dry-rb/dry-types/compare/v0.9.1...v0.9.2)
394
+
395
+ # v0.9.1 2016-11-04
396
+
397
+ ## Fixed
398
+
399
+ - `Hash#strict_with_defaults` properly evaluates callable defaults (bolshakov)
400
+
401
+ ## Changed
402
+
403
+ - `Hash#weak` accepts Hash-descendants again (solnic)
404
+
405
+ [Compare v0.9.0...v0.9.1](https://github.com/dry-rb/dry-types/compare/v0.9.0...v0.9.1)
406
+
1
407
  # v0.9.0 2016-09-21
2
408
 
3
409
  ## Added
4
410
 
5
- * `Hash#strict_with_defaults` which validates presence of all required keys and respects default types for missing *values* (backus)
6
- * `Type#constrained?` method (flash-gordon)
411
+ - `Hash#strict_with_defaults` which validates presence of all required keys and respects default types for missing _values_ (backus)
412
+ - `Type#constrained?` method (flash-gordon)
7
413
 
8
414
  ## Fixed
9
415
 
10
- * Summing two constrained types works correctly (flash-gordon)
11
- * `Types::Array::Member#valid?` in cases where member type is a constraint (solnic)
12
- * `Hash::Schema#try` handles exceptions properly and returns a failure object (solnic)
416
+ - Summing two constrained types works correctly (flash-gordon)
417
+ - `Types::Array::Member#valid?` in cases where member type is a constraint (solnic)
418
+ - `Hash::Schema#try` handles exceptions properly and returns a failure object (solnic)
13
419
 
14
420
  ## Changed
15
421
 
16
- * [BREAKING] Renamed `Hash##{schema=>permissive}` (backus)
17
- * [BREAKING] `dry-monads` dependency was made optional, Maybe types are available after `Dry::Types.load_extension(:maybe)` (flash-gordon)
18
- * [BREAKING] `Dry::Types::Struct` and `Dry::Types::Value` have been extracted to [`dry-struct`](https://github.com/dry-rb/dry-struct) (backus)
19
- * `Types::Form::Bool` supports upcased true/false values (kirs)
20
- * `Types::Form::{Date,DateTime,Time}` fail gracefully for invalid input (padde)
21
- * ice_nine dependency has been dropped as it was required by Struct only (flash-gordon)
422
+ - [BREAKING] Renamed `Hash##{schema=>permissive}` (backus)
423
+ - [BREAKING] `dry-monads` dependency was made optional, Maybe types are available after `Dry::Types.load_extensions(:maybe)` (flash-gordon)
424
+ - [BREAKING] `Dry::Types::Struct` and `Dry::Types::Value` have been extracted to [`dry-struct`](https://github.com/dry-rb/dry-struct) (backus)
425
+ - `Types::Form::Bool` supports upcased true/false values (kirs)
426
+ - `Types::Form::{Date,DateTime,Time}` fail gracefully for invalid input (padde)
427
+ - ice_nine dependency has been dropped as it was required by Struct only (flash-gordon)
22
428
 
23
- [Compare v0.8.1...v0.9.0](https://github.com/dryrb/dry-types/compare/v0.8.1...v0.9.0)
429
+ [Compare v0.8.1...v0.9.0](https://github.com/dry-rb/dry-types/compare/v0.8.1...v0.9.0)
24
430
 
25
431
  # v0.8.1 2016-07-13
26
432
 
27
433
  ## Fixed
28
434
 
29
- * Compiler no longer chokes on type nodes without args (solnic)
30
- * Removed `bin/console` from gem package (solnic)
435
+ - Compiler no longer chokes on type nodes without args (solnic)
436
+ - Removed `bin/console` from gem package (solnic)
31
437
 
32
- [Compare v0.8.0...v0.8.1](https://github.com/dryrb/dry-types/compare/v0.8.0...v0.8.1)
438
+ [Compare v0.8.0...v0.8.1](https://github.com/dry-rb/dry-types/compare/v0.8.0...v0.8.1)
33
439
 
34
440
  # v0.8.0 2016-07-01
35
441
 
36
442
  ## Added
37
443
 
38
- * `Struct` now implements `Type` interface so ie `SomeStruct | String` works now (flash-gordon)
39
- * `:weak` Hash constructor which can partially coerce a hash even when it includes invalid values (solnic)
40
- * Types include `Dry::Equalizer` now (flash-gordon)
444
+ - `Struct` now implements `Type` interface so ie `SomeStruct | String` works now (flash-gordon)
445
+ - `:weak` Hash constructor which can partially coerce a hash even when it includes invalid values (solnic)
446
+ - Types include `Dry::Equalizer` now (flash-gordon)
41
447
 
42
448
  ## Fixed
43
449
 
44
- * `Struct#to_hash` descends into arrays too (nepalez)
45
- * `Default#with` works now (flash-gordon)
450
+ - `Struct#to_hash` descends into arrays too (nepalez)
451
+ - `Default#with` works now (flash-gordon)
46
452
 
47
453
  ## Changed
48
454
 
49
- * `:symbolized` hash schema is now based on `:weak` schema (solnic)
50
- * `Struct::Value` instances are now **deeply frozen** via ice_nine (backus)
455
+ - `:symbolized` hash schema is now based on `:weak` schema (solnic)
456
+ - `Struct::Value` instances are now **deeply frozen** via ice_nine (backus)
51
457
 
52
- [Compare v0.7.2...v0.8.0](https://github.com/dryrb/dry-types/compare/v0.7.2...v0.8.0)
458
+ [Compare v0.7.2...v0.8.0](https://github.com/dry-rb/dry-types/compare/v0.7.2...v0.8.0)
53
459
 
54
460
  # v0.7.2 2016-05-11
55
461
 
@@ -68,7 +474,7 @@
68
474
  - Coerce empty strings in form posts to blank arrays and hashes (timriley)
69
475
  - update to use dry-logic v0.2.3 (fran-worley)
70
476
 
71
- [Compare v0.7.1...v0.7.2](https://github.com/dryrb/dry-types/compare/v0.7.1...v0.7.2)
477
+ [Compare v0.7.1...v0.7.2](https://github.com/dry-rb/dry-types/compare/v0.7.1...v0.7.2)
72
478
 
73
479
  # v0.7.1 2016-04-06
74
480
 
@@ -81,7 +487,7 @@
81
487
  - Schema is properly inherited in Struct (backus)
82
488
  - `constructor_type` is properly inherited in Struct (fbernier)
83
489
 
84
- [Compare v0.7.0...v0.7.1](https://github.com/dryrb/dry-types/compare/v0.7.0...v0.7.1)
490
+ [Compare v0.7.0...v0.7.1](https://github.com/dry-rb/dry-types/compare/v0.7.0...v0.7.1)
85
491
 
86
492
  # v0.7.0 2016-03-30
87
493
 
@@ -115,7 +521,7 @@ Major focus of this release is to make complex type composition possible and imp
115
521
  - `Type#default` will raise if `nil` was passed for `Maybe` type (solnic)
116
522
  - `Hash` with a schema will set maybe values for missing keys or nils (flash-gordon)
117
523
 
118
- [Compare v0.6.0...v0.7.0](https://github.com/dryrb/dry-types/compare/v0.6.0...v0.7.0)
524
+ [Compare v0.6.0...v0.7.0](https://github.com/dry-rb/dry-types/compare/v0.6.0...v0.7.0)
119
525
 
120
526
  # v0.6.0 2016-03-16
121
527
 
@@ -123,165 +529,165 @@ Renamed from `dry-data` to `dry-types` and:
123
529
 
124
530
  ## Added
125
531
 
126
- * `Dry::Types.module` which returns a namespace for inclusion which has all
532
+ - `Dry::Types.module` which returns a namespace for inclusion which has all
127
533
  built-in types defined as constants (solnic)
128
- * `Hash#schema` supports default values now (solnic)
129
- * `Hash#symbolized` passes through keys that are already symbols (solnic)
130
- * `Struct.new` uses an empty hash by default as input (solnic)
131
- * `Struct.constructor_type` macro can be used to change attributes constructor (solnic)
132
- * `default` accepts a block now for dynamic values (solnic)
133
- * `Types.register_class` accepts a second arg which is the name of the class'
534
+ - `Hash#schema` supports default values now (solnic)
535
+ - `Hash#symbolized` passes through keys that are already symbols (solnic)
536
+ - `Struct.new` uses an empty hash by default as input (solnic)
537
+ - `Struct.constructor_type` macro can be used to change attributes constructor (solnic)
538
+ - `default` accepts a block now for dynamic values (solnic)
539
+ - `Types.register_class` accepts a second arg which is the name of the class'
134
540
  constructor method, defaults to `:new` (solnic)
135
541
 
136
542
  ## Fixed
137
543
 
138
- * `Struct` will simply pass-through the input if it is already a struct (solnic)
139
- * `default` will raise if a value violates constraints (solnic)
140
- * Evaluating a default value tries to use type's constructor which makes it work
544
+ - `Struct` will simply pass-through the input if it is already a struct (solnic)
545
+ - `default` will raise if a value violates constraints (solnic)
546
+ - Evaluating a default value tries to use type's constructor which makes it work
141
547
  with types that may coerce an input into nil (solnic)
142
- * `enum` works just fine with integer-values (solnic)
143
- * `enum` + `default` works just fine (solnic)
144
- * `Optional` no longer responds to `primitive` as it makes no sense since there's
548
+ - `enum` works just fine with integer-values (solnic)
549
+ - `enum` + `default` works just fine (solnic)
550
+ - `Optional` no longer responds to `primitive` as it makes no sense since there's
145
551
  no single primitive for an optional value (solnic)
146
- * `Optional` passes-through a value which is already a maybe (solnic)
552
+ - `Optional` passes-through a value which is already a maybe (solnic)
147
553
 
148
554
  ## Changed
149
555
 
150
- * `Dry::Types::Definition` is now the base type definition object (solnic)
151
- * `Dry::Types::Constructor` is now a type definition with a constructor function (solnic)
556
+ - `Dry::Types::Definition` is now the base type definition object (solnic)
557
+ - `Dry::Types::Constructor` is now a type definition with a constructor function (solnic)
152
558
 
153
- [Compare v0.5.1...v0.6.0](https://github.com/dryrb/dry-types/compare/v0.5.1...v0.6.0)
559
+ [Compare v0.5.1...v0.6.0](https://github.com/dry-rb/dry-types/compare/v0.5.1...v0.6.0)
154
560
 
155
561
  # v0.5.1 2016-01-11
156
562
 
157
563
  ## Added
158
564
 
159
- * `Dry::Data::Type#safe` for types which can skip constructor when primitive does
565
+ - `Dry::Data::Type#safe` for types which can skip constructor when primitive does
160
566
  not match input's class (solnic)
161
- * `form.array` and `form.hash` safe types (solnic)
567
+ - `form.array` and `form.hash` safe types (solnic)
162
568
 
163
- [Compare v0.5.0...v0.5.1](https://github.com/dryrb/dry-types/compare/v0.5.0...v0.5.1)
569
+ [Compare v0.5.0...v0.5.1](https://github.com/dry-rb/dry-types/compare/v0.5.0...v0.5.1)
164
570
 
165
571
  # v0.5.0 2016-01-11
166
572
 
167
573
  ## Added
168
574
 
169
- * `Type#default` interface for defining a type with a default value (solnic)
575
+ - `Type#default` interface for defining a type with a default value (solnic)
170
576
 
171
577
  ## Changed
172
578
 
173
- * [BREAKING] `Dry::Data::Type.new` accepts constructor and *options* now (solnic)
174
- * Renamed `Dry::Data::Type::{Enum,Constrained}` => `Dry::Data::{Enum,Constrained}` (solnic)
175
- * `dry-logic` is now a dependency for constrained types (solnic)
176
- * Constrained types are now always available (solnic)
177
- * `strict.*` category uses constrained types with `:type?` predicate (solnic)
178
- * `SumType#call` no longer needs to rescue from `TypeError` (solnic)
579
+ - [BREAKING] `Dry::Data::Type.new` accepts constructor and _options_ now (solnic)
580
+ - Renamed `Dry::Data::Type::{Enum,Constrained}` => `Dry::Data::{Enum,Constrained}` (solnic)
581
+ - `dry-logic` is now a dependency for constrained types (solnic)
582
+ - Constrained types are now always available (solnic)
583
+ - `strict.*` category uses constrained types with `:type?` predicate (solnic)
584
+ - `SumType#call` no longer needs to rescue from `TypeError` (solnic)
179
585
 
180
586
  ## Fixed
181
587
 
182
- * `attribute` raises proper error when type definition is missing (solnic)
588
+ - `attribute` raises proper error when type definition is missing (solnic)
183
589
 
184
- [Compare v0.4.2...v0.5.0](https://github.com/dryrb/dry-types/compare/v0.4.2...v0.5.0)
590
+ [Compare v0.4.2...v0.5.0](https://github.com/dry-rb/dry-types/compare/v0.4.2...v0.5.0)
185
591
 
186
592
  # v0.4.2 2015-12-27
187
593
 
188
594
  ## Added
189
595
 
190
- * Support for arrays in type compiler (solnic)
596
+ - Support for arrays in type compiler (solnic)
191
597
 
192
598
  ## Changed
193
599
 
194
- * Array member uses type objects now rather than just their constructors (solnic)
600
+ - Array member uses type objects now rather than just their constructors (solnic)
195
601
 
196
- [Compare v0.4.1...v0.4.2](https://github.com/dryrb/dry-types/compare/v0.4.1...v0.4.2)
602
+ [Compare v0.4.1...v0.4.2](https://github.com/dry-rb/dry-types/compare/v0.4.1...v0.4.2)
197
603
 
198
604
  # v0.4.0 2015-12-11
199
605
 
200
606
  ## Added
201
607
 
202
- * Support for sum-types with constraint type (solnic)
203
- * `Dry::Data::Type#optional` for defining optional types (solnic)
608
+ - Support for sum-types with constraint type (solnic)
609
+ - `Dry::Data::Type#optional` for defining optional types (solnic)
204
610
 
205
611
  ## Changed
206
612
 
207
- * `Dry::Data['optional']` was **removed** in favor of `Dry::Data::Type#optional` (solnic)
613
+ - `Dry::Data['optional']` was **removed** in favor of `Dry::Data::Type#optional` (solnic)
208
614
 
209
- [Compare v0.3.2...v0.4.0](https://github.com/dryrb/dry-types/compare/v0.3.2...v0.4.0)
615
+ [Compare v0.3.2...v0.4.0](https://github.com/dry-rb/dry-types/compare/v0.3.2...v0.4.0)
210
616
 
211
617
  # v0.3.2 2015-12-10
212
618
 
213
619
  ## Added
214
620
 
215
- * `Dry::Data::Value` which works like a struct but is a value object with equalizer (solnic)
621
+ - `Dry::Data::Value` which works like a struct but is a value object with equalizer (solnic)
216
622
 
217
623
  ## Fixed
218
624
 
219
- * Added missing require for `dry-equalizer` (solnic)
625
+ - Added missing require for `dry-equalizer` (solnic)
220
626
 
221
- [Compare v0.3.1...v0.3.2](https://github.com/dryrb/dry-types/compare/v0.3.1...v0.3.2)
627
+ [Compare v0.3.1...v0.3.2](https://github.com/dry-rb/dry-types/compare/v0.3.1...v0.3.2)
222
628
 
223
629
  # v0.3.1 2015-12-09
224
630
 
225
631
  ## Changed
226
632
 
227
- * Removed require of constrained type and make it optional (solnic)
633
+ - Removed require of constrained type and make it optional (solnic)
228
634
 
229
- [Compare v0.3.0...v0.3.1](https://github.com/dryrb/dry-types/compare/v0.3.0...v0.3.1)
635
+ [Compare v0.3.0...v0.3.1](https://github.com/dry-rb/dry-types/compare/v0.3.0...v0.3.1)
230
636
 
231
637
  # v0.3.0 2015-12-09
232
638
 
233
639
  ## Added
234
640
 
235
- * `Type#constrained` interface for defining constrained types (solnic)
236
- * `Dry::Data` can be configured with a type namespace (solnic)
237
- * `Dry::Data.finalize` can be used to define types as constants under configured namespace (solnic)
238
- * `Dry::Data::Type#enum` for defining an enum from a specific type (solnic)
239
- * New types: `symbol` and `class` along with their `strict` versions (solnic)
641
+ - `Type#constrained` interface for defining constrained types (solnic)
642
+ - `Dry::Data` can be configured with a type namespace (solnic)
643
+ - `Dry::Data.finalize` can be used to define types as constants under configured namespace (solnic)
644
+ - `Dry::Data::Type#enum` for defining an enum from a specific type (solnic)
645
+ - New types: `symbol` and `class` along with their `strict` versions (solnic)
240
646
 
241
- [Compare v0.2.1...v0.3.0](https://github.com/dryrb/dry-types/compare/v0.2.1...v0.3.0)
647
+ [Compare v0.2.1...v0.3.0](https://github.com/dry-rb/dry-types/compare/v0.2.1...v0.3.0)
242
648
 
243
649
  # v0.2.1 2015-11-30
244
650
 
245
651
  ## Added
246
652
 
247
- * Type compiler supports nested hashes now (solnic)
653
+ - Type compiler supports nested hashes now (solnic)
248
654
 
249
655
  ## Fixed
250
656
 
251
- * `form.bool` sum is using correct right-side `form.false` type (solnic)
657
+ - `form.bool` sum is using correct right-side `form.false` type (solnic)
252
658
 
253
659
  ## Changed
254
660
 
255
- * Improved structure of the ast (solnic)
661
+ - Improved structure of the ast (solnic)
256
662
 
257
- [Compare v0.2.0...v0.2.1](https://github.com/dryrb/dry-types/compare/v0.2.0...v0.2.1)
663
+ [Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-types/compare/v0.2.0...v0.2.1)
258
664
 
259
665
  # v0.2.0 2015-11-29
260
666
 
261
667
  ## Added
262
668
 
263
- * `form.nil` which coerces empty strings to `nil` (solnic)
264
- * `bool` sum-type (true | false) (solnic)
265
- * Type compiler supports sum-types now (solnic)
669
+ - `form.nil` which coerces empty strings to `nil` (solnic)
670
+ - `bool` sum-type (true | false) (solnic)
671
+ - Type compiler supports sum-types now (solnic)
266
672
 
267
673
  ## Changed
268
674
 
269
- * Constructing optional types uses the new `Dry::Data["optional"]` built-in type (solnic)
675
+ - Constructing optional types uses the new `Dry::Data["optional"]` built-in type (solnic)
270
676
 
271
- [Compare v0.1.0...v0.2.0](https://github.com/dryrb/dry-types/compare/v0.1.0...v0.2.0)
677
+ [Compare v0.1.0...v0.2.0](https://github.com/dry-rb/dry-types/compare/v0.1.0...v0.2.0)
272
678
 
273
679
  # v0.1.0 2015-11-27
274
680
 
275
681
  ## Added
276
682
 
277
- * `form.*` coercible types (solnic)
278
- * `Type::Hash#strict` for defining hashes with a strict schema (solnic)
279
- * `Type::Hash#symbolized` for defining hashes that will symbolize keys (solnic)
280
- * `Dry::Data.register_class` short-cut interface for registering a class and
683
+ - `form.*` coercible types (solnic)
684
+ - `Type::Hash#strict` for defining hashes with a strict schema (solnic)
685
+ - `Type::Hash#symbolized` for defining hashes that will symbolize keys (solnic)
686
+ - `Dry::Data.register_class` short-cut interface for registering a class and
281
687
  setting its `.new` method as the constructor (solnic)
282
- * `Dry::Data::Compiler` for building a type from a simple ast (solnic)
688
+ - `Dry::Data::Compiler` for building a type from a simple ast (solnic)
283
689
 
284
- [Compare v0.0.1...HEAD](https://github.com/dryrb/dry-types/compare/v0.0.1...HEAD)
690
+ [Compare v0.0.1...HEAD](https://github.com/dry-rb/dry-types/compare/v0.0.1...HEAD)
285
691
 
286
692
  # v0.0.1 2015-10-05
287
693