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