Typed
Description
Typed
is a dry-types
+ dry-struct
alternative. It provides a similar API in order to ease migration.
Compared to dry-struct
, Typed
has an improved support of "nullable" and "missable" fields:
-
Typed::String.nullable
: accepts aString
, orNil
. -
Typed::String.missable
: accepts aString
, or no value at all (represented byTyped::Undefined
). -
Typed::String.nullable.missable
: accepts aString
,Nil
, or no value at all (represented byTyped::Undefined
). This behavior is difficult to obtain withdry-struct
.
Typed
only targets the use-case of converting controller parameters into Ruby objects with proper type checks and coercions.
Install
gem 'bm-typed', require: 'typed'
Documentation
Not yet.
Maturity
This gem is a PoC and it shouldn't be considered production-ready.
License
Copyright (c) 2018 Bannerman, Frederic Terrazzoni
Licensed under the MIT license.