Skip to content

Commit 8deebb5

Browse files
authored
Merge pull request #2017 from stanhu/sh-upgrade-notice-for-array-integerss
Add upgrade notice on upgrading all Array types
2 parents 5a3c2f2 + 2a5f6c5 commit 8deebb5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

UPGRADING.md

+9-3
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)