-
-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nullable modifier #163
Comments
We are unlikely to add this as we feel |
|
I'd also like to support the idea of having a Originally, I wanted to submit an issue to discuss standardization of exception messages, but having a nullable validator that'd merge the message would work as well. Current:
Preferred:
|
Sorry for my english and my persistence. Why not use the following syntax instead of ow.number.or.string; ? ow.number.or.null;
ow.number.or.null.or.undefined; It is also not clear why need the types for
In all the above examples, no int8Array is possible. Maybe for smaller size it's better to limit types to possible in json plus undefined and maybe some commonly used types? UPDATE: UPDATE2: Probably a bit crude implementation, but already quite working: @riim/type. |
I have changed my mind. It does indeed make sense to add this here as you can't control what other APIs use. PR welcome. I still want a link to sindresorhus/meta#7 in the docs to try to convince people to not use |
You should still open an issue about this for other use-cases. We've tried to keep the messages consistent, but I'm sure we missed some cases. |
I don't remember exactly why we didn't do it this way. It does look nice, but there are ambiguous cases: ow.string.length(3).and.string.uppercase.or.string.includes('f') Does this mean it accepts |
In omyumyum i use om.object.shape({ name: om.string }).and.custom(
om.object.shape({ age: om.number })
.or.object.shape({ birthday: om.date })]
); |
ow.nullable.string
instead of
ow.any(ow.string, ow.null)
A generic modifier for
|null|undefined
would also be useful. Maybe it is better ifoptional
will also allownull
? In most cases, you need|null|undefined
and|null
. Separately,|undefined
is needed almost never.The text was updated successfully, but these errors were encountered: