cypriss / mutations

Compose your business logic into commands that sanitize and validate input.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to handle multiple types

aliceclv opened this issue Β· comments

commented

How would you normally handle a parameter that has multiple types?
I have a hash, containing a key channel_id that can be either string or integer.

Thanks a lot for your help πŸ™ !

hash :setup do
  integer :channel_id
  string :channel_id
end

If it's an integer in a stringformat just use integer. Otherwise take a look at this page:
https://github.com/cypriss/mutations/wiki/Filtering-Input

Alternatively, you may need to add your own custom type, would be nice if the docs included how to go about that though without digging into the codebase.