Skip to content

Change proposal: Consider Vest for user-facing validations in the Epic Stack #604

@ealush

Description

@ealush

Hey 👋
Thanks for making the Epic Stack. I believe it brings actual value to the developer community. I'd like to propose considering Vest as an alternative or complementary option to Zod for user-facing validations.

*Disclaimer, I am the author of Vest

Obviously, I don't expect it to be added just because I asked here, and I want to make a proposal PR to make my point. I know reviewing PRs can be a burden so I haven't yet created a PR - I wanted to ask here first before I make a proposal PR.

Here are the broad details that I am going to implement in my PR:

What

  1. Add Vest validations library alongside Zod or instead of it
  2. Add examples for user facing validations, adding examples of interactive validations
  3. Update relevant docs to reflect this option.

Why

I see the value in the Epic Stack as an opinionated tech stack, and that it can greatly boost the productivity of people building their apps.

I believe Vest can improve their productivity, and allow for capabilities currently not possible with Zod, or very hard to implement, along with improving the end-user experience, especially around async validation, as each validation can be async individually and report back immediately as it finishes.

Vest validates each field as the user types, rather than the entire schema, so no need to break the form down into different smaller schemas.

Its declarative unit-testing-like syntax can reduce the complexity of imperative validations like this:

export const PasswordAndConfirmPasswordSchema = z
.object({ password: PasswordSchema, confirmPassword: PasswordSchema })
.superRefine(({ confirmPassword, password }, ctx) => {
if (confirmPassword !== password) {
ctx.addIssue({
path: ['confirmPassword'],
code: 'custom',
message: 'The passwords must match',
})
}
})

Would have changed to:

test("confirmPassword", "Passwords do not match", () => {
  enforce(data.confirmPassword).equals(data.password);
});

Of course, I'm also open to your feedback and insights on whether this proposed change aligns with the Epic Stack's vision.

Thanks for your time and consideration!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions