Skip to content

validationError for client side? #96

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

You must be logged in to vote

We don't currently have an API that does this, but it would be pretty straightforward to add. On the client side we could simplify it a lot and just have a setErrors helper returned from useFormContext. And maybe we could pass that directly to onSubmit.

Something like this maybe?

onSubmit={async (data, event, formContext) => {
  const { setErrors } = formContext;
  const isValid = await supabaseValidation(data);
  if (!isValid) {
    setErrors({ myField: 'Error!' });
    event.preventDefault();
  }
}}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@niklasgrewe
Comment options

@mtin79
Comment options

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