Skip to content

Conversation

@ianmacartney
Copy link
Collaborator

Add a validate(validator, value) helper


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ianmacartney ianmacartney requested a review from ldanilek February 4, 2025 03:14
Copy link
Contributor

@ldanilek ldanilek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

const accountWithoutBalance = omit(vv.doc("accounts").fields, ["balance"]);

// Validate against a validator. Can optionally throw on error.
validate(balanceAndEmail, { balance: 123n, email: "[email protected]" });
Copy link
Contributor

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({
Copy link
Contributor

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

@ianmacartney ianmacartney merged commit fcc216b into main Feb 5, 2025
1 check failed
@ianmacartney ianmacartney deleted the ian/validate branch July 9, 2025 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants