Skip to content

Commit 2a5f6c5

Browse files
committed
Add upgrade notice on upgrading all Array types
Previously Vitrus implicitly coerced strings to integers when Array[Integer] types were used. With dry-types, this is no longer done, and APIs that expected this behavior will fail with an invalid type check. Expand the upgrade docs to include all Array types and an example for Array[Integer].
1 parent 5a3c2f2 commit 2a5f6c5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

UPGRADING.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ end
4242

4343
Custom types which don't depend on Virtus don't require any changes.
4444

45-
#### Ensure that Array[String] types have explicit coercions
45+
#### Ensure that Array types have explicit coercions
4646

4747
Unlike Virtus, dry-types does not perform any implict coercions. If you
48-
have any uses of `Array[String]`, be sure they use a `coerce_with`
49-
block. For example:
48+
have any uses of `Array[String]`, `Array[Integer]`, etc. be sure they
49+
use a `coerce_with` block. For example:
5050

5151
```ruby
5252
requires :values, type: Array[String]
@@ -62,6 +62,12 @@ you might do:
6262
requires :values, type: Array[String], coerce_with: ->(val) { val.split(',').map(&:strip) }
6363
```
6464

65+
Likewise, for `Array[Integer]`, you might do:
66+
67+
```ruby
68+
requires :values, type: Array[Integer], coerce_with: ->(val) { val.split(',').map(&:strip).map(&:to_i) }
69+
```
70+
6571
For more information see [#1920](https://github.com/ruby-grape/grape/pull/1920).
6672

6773
### Upgrading to >= 1.2.4

0 commit comments

Comments
 (0)