Skip to content

Type inference in with predefined types #408

Answered by fabian-hiller
ColemanDunn asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you for creating this discussion. I would write it like this:

import * as v from 'valibot';

type LoginData = {
  email: string;
  password: string;
};

const LoginSchema = v.object({
  email: v.string([v.email()]),
  password: v.string([v.minLength(8)]),
}) satisfies v.BaseSchema<LoginData>;

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ColemanDunn
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants