defaulted
defaulted
augments a struct to add coercion logic for default values, which are applied when the input is undefined
.🤖 If you adddefaulted
to anobject
struct with a dictionary of values, those values will be mixed in one-by-one, so the input doesn't need to beundefined
, but certain properties can beundefined
.
trimmed
trimmed
arguments a struct to ensure that any string input values are trimmed.coerce
is a struct narrowing the types of input values you want to try coercion. In the example above, the coercion functionn will only ever be called when the input is a string—booleans would ignore coercion and fail normally.🤖 If you want to run coercion for any type of input, use theunknown()
struct to run it in all cases.