-
-
Notifications
You must be signed in to change notification settings - Fork 172
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
Skip pipeline when calling is() #166
Conversation
✅ Deploy Preview for valibot ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
To just check the data type, you are right and it can be added. However, I would add it as a configuration and leave it as it is by default. I strongly suspect that this is the expected behavior of most Valibot users. // Default behaviour with pipes
is(Schema, input);
// Skip pipes and only check data type
is(Schema, input, { skipPipe: true });
// Or just with an boolean
is(Schema, input, true); |
Yep fair enough! I guess it depends on the primary purpose of |
If you are interested in this feature, you can implement it. Otherwise we can wait for feedback from other people. |
Yep happy to implement, @fabian-hiller 🙂 I do think it might be worth waiting for some more opinions though, if that's ok. I'm undecided about what might be the best option. To add to the options you've listed above: // Might be more clearly represented with an opt-out approach
is(Schema, input, false);
// Function signature would be
export function is<TSchema extends BaseSchema>(
schema: TSchema,
input: unknown,
runPipe = true
): input is Input<TSchema> {
return !schema._parse(input, { abortEarly: true, skipPipe: !runPipe }).issues;
} Would be good to hear from others what they might expect the behaviour of |
I think that if someone defines the schema Maybe we should implement it explicitly with |
Yeah I do agree with you, @fabian-hiller. Definitely good to keep consistent with I've added the |
I would agree, I would expect a schema passed to |
I added // Skip pipes and only check data type
is(Schema, input, { skipPipe: true }); |
As
is()
is primarily designed for use as a type guard, it would make sense to skip pipelines during this check too 🙂Currently:
Proposed:
Notes
This is a breaking change to
is()
Following on from #164.