Skip to content
Discussion options

You must be logged in to vote

hey @BittuChan !

The key is that pipe wraps the whole object, not the individual fields because cross-field validation happens at the object level.

Minimal example:

import * as v from 'valibot';

const RegisterSchema = v.pipe(
  v.object({
    email: v.pipe(
      v.string(),
      v.nonEmpty('Email is required.'),
      v.email('Invalid email format.')
    ),
    password: v.pipe(
      v.string(),
      v.nonEmpty('Password is required.'),
      v.minLength(8, 'Must be at least 8 characters.')
    ),
    confirmPassword: v.string(),
  }),
  v.forward(
    v.partialCheck(
      [['password'], ['confirmPassword']],
      (input) => input.password === input.confirmPassword,
      'Password…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@BittuChan
Comment options

Answer selected by BittuChan
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