-
-
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
Add object predicate #48
Conversation
477f053
to
64c5002
Compare
64c5002
to
e7dbd96
Compare
Implemented all of them. One thing I wasn't sure about, is if we should support dot properties with something like dot-prop. This could be nice for the Somewhat related to the dot properties. Should we support nested objects in |
* | ||
* @param keys The keys that should be present in the object. | ||
*/ | ||
hasKeys(...keys: string[]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make this (and elsewhere) hasAllKeys()
? I'm starting to doubt it's clear enough whether it's all keys or any keys if the user hasn't seen hasAnyKeys()
yet.
Looking good :) |
Yeah, that could be useful.
What would that look like? I'm not sure I understand. |
For instance, this will fail because it only checks the values at root level ( const input = {
foo: 'bar',
unicorn: {
rainbow: 'rainbow'
}
};
ow(input, ow.object.valuesOfType(ow.string)); If we support nested objects, the previous example will succeed. |
I think that would be surprising behavior by default, but I can see the use-case for it. So, either a |
I think I'm more in favour of ow(input, ow.object.valuesOfType(ow.string.minLength(4), {deep: true}));
ow(input, ow.object.valuesOfTypeDeep(ow.string.minLength(4))); It's also in the same fashion as |
👍 |
Still work in progress