You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The thing about "defaults" is that they're much more useful if appended at the end (or in the middle of) a validation chain.
The validator contract is: if receiving null or undefined at input, you must return null or undefined respectively at output. toi.required is the only one allowed to break the contract, to disallow nulls or undefined.
So generally toi.required starts the chain if you really don't want any nulls. toi.optional does almost nothing, except that it strictly types the start as having something | null.
The default then should maybe come at the end of a chain (or proper place):
toi.optional()// possible null values.and(toi.str.is())// but must be a string if present.and(toi.default("STRING"))// if null or undefined
something like:
or just:
The text was updated successfully, but these errors were encountered: