-
-
Notifications
You must be signed in to change notification settings - Fork 215
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
Add a simple customPartial implementation #223
Conversation
✅ Deploy Preview for valibot canceled.
|
Thank you for the draft! |
Do you have any alternative name ideas for |
Beside PR #211, I would like to focus on a solution to this problem in the next week. It will also be important to be able to specify the path where the error message should be applied. |
Maybe something like |
b997a0f
to
6d0cde4
Compare
I have added a import * as v from 'valibot';
const RegisterSchema = v.pipe(
v.object({
email: v.pipe(
v.string(),
v.nonEmpty('Please enter your email.'),
v.email('The email address is badly formatted.'),
),
password1: v.pipe(
v.string(),
v.nonEmpty('Please enter your password.'),
v.minLength(8, 'Your password must have 8 characters or more.'),
),
password2: v.string(),
}),
v.forward(
v.partialCheck(
[['password1'], ['password2']],
(input) => input.password1 === input.password2,
'The two passwords do not match.',
),
['password2'],
),
); |
Related #76
This is an extremely simplified implementation of the proposed “partial pipe” solution.