Skip to content

Commit

Permalink
update README with instructions on sum types
Browse files Browse the repository at this point in the history
I had to look into specs to discover that this behavior was supported:

https://github.com/dry-rb/dry-schema/blob/main/spec/integration/params/macros/value_spec.rb#L31

I feel this is a very useful pattern, and that making it more
discoverable will be more user-friendly.
  • Loading branch information
timhwang21 committed Oct 21, 2024
1 parent ced2c60 commit e962d49
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docsite/source/basics/macros.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ Dry::Schema.Params do
end
```

Predicates passed as an array will be `OR`-ed automatically:

```ruby
Dry::Schema.Params do
# expands to `required(:id) { str? | int? }`
required(:id).value([:string, :integer])
end
```

### filled

Use it when a value is expected to be filled. "filled" means that the value is non-nil and, in the case of a `String`, `Hash`, or `Array` value, that the value is not `.empty?`.
Expand Down

0 comments on commit e962d49

Please sign in to comment.