Skip to content

Check if a single field isValid #228

Answered by airjp73
piotrkulpinski asked this question in Q&A
Discussion options

You must be logged in to vote

I think the only way to do this without actually validating the field is to go around the library a bit rather than going through it.

const context = useFormContext();

async function checkFieldValidity() {
  // This check might not be 100% correct but should be close
  const result = await validator.validateField(context.getValues(), 'myField');
  const isValid = !!result.error;
  return isValid;
}

Replies: 1 comment 1 reply

Comment options

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

Answer selected by piotrkulpinski
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants