Skip to content

Commit

Permalink
Merge pull request #2017 from stanhu/sh-upgrade-notice-for-array-inte…
Browse files Browse the repository at this point in the history
…gerss

Add upgrade notice on upgrading all Array types
  • Loading branch information
dblock authored Mar 17, 2020
2 parents 5a3c2f2 + 2a5f6c5 commit 8deebb5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ end

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

#### Ensure that Array[String] types have explicit coercions
#### Ensure that Array types have explicit coercions

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

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

Likewise, for `Array[Integer]`, you might do:

```ruby
requires :values, type: Array[Integer], coerce_with: ->(val) { val.split(',').map(&:strip).map(&:to_i) }
```

For more information see [#1920](https://github.com/ruby-grape/grape/pull/1920).

### Upgrading to >= 1.2.4
Expand Down

0 comments on commit 8deebb5

Please sign in to comment.