These are chat archives for dry-rb/chat

12th
Oct 2018
Alex Park
@alexspark
Oct 12 2018 18:03
Hi all, new to all thing dry here, i really like the APIs. Can someone guide me on how to coerce boolean strings but protect against weird strings like 'please'. attribute :active, Types::Params::Bool.constrained(included_in: [true, false]) throws errors in the gem
Alex Park
@alexspark
Oct 12 2018 18:10
One work around I've thought of is to constrain the attribute as a string to only be one of 'true' or 'false', then try to coerce to boolean
Igor Alexandrov
@igor-alexandrov
Oct 12 2018 19:12
you don't need constrained with Types::Params::Bool
because Types::Params::Bool already converts everything to true or false
Alex Park
@alexspark
Oct 12 2018 19:14
but Types::Params::Bool['please'] returns 'please', and I don't want to assume sensible inputs.
which abstraction should i use to ensure only 'true' and 'false strings as input
Igor Alexandrov
@igor-alexandrov
Oct 12 2018 19:15
I see...
From my point of view it is a bug...
please start an Issue
I will try to take a look
Alex Park
@alexspark
Oct 12 2018 19:29