Skip to content

Using custom with a predefined schema? #508

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

You must be logged in to vote

This is already possible, but I am aware that it is a bit cumbersome. That's why we're currently changing that part of the API in #502.

Check the code out in our playground

import * as v from 'valibot';

const FooSchema = v.object({ foo: v.string([v.toTrimmed(), v.email()]) });

const ExtendedFoo = v.object(FooSchema.entries, [
  v.custom(({ foo }) => foo.includes('@gmail'), 'Error: Not a Gmail!')
]);

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@fabian-hiller
Comment options

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