Skip to content

How to validate name of a function? #817

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

You must be logged in to vote

You should use check instead of custom. Try it out in our playground.

import * as v from 'valibot';

const Schema = v.pipe(
  v.function(),
  v.check(
    (func) => func.name === 'foo',
    (issue) => `The name is "${issue.input.name}" instead of "foo"`,
  ),
);

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@fabian-hiller
Comment options

@itsramiel
Comment options

Answer selected by fabian-hiller
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