-
Notifications
You must be signed in to change notification settings - Fork 20
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
Ian/validate #434
Ian/validate #434
Conversation
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.
nice!
@@ -666,6 +669,9 @@ const balanceAndEmail = pick(vv.doc("accounts").fields, ["balance", "email"]); | |||
|
|||
// A validator for all the fields except balance. | |||
const accountWithoutBalance = omit(vv.doc("accounts").fields, ["balance"]); | |||
|
|||
// Validate against a validator. Can optionally throw on error. | |||
validate(balanceAndEmail, { balance: 123n, email: "[email protected]" }); |
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.
worth putting a oneline v.id warning here?
}); | ||
|
||
test("includes path in error messages", () => { | ||
const complexValidator = object({ |
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.
the array pathPrefix is also interesting
Add a
validate(validator, value)
helperBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.