fireship.io icon indicating copy to clipboard operation
fireship.io copied to clipboard

courses/react-next-firebase/admin-form-validation/

Open utterances-bot opened this issue 2 years ago • 2 comments

Form Validation

Add form validation with react-hook-forms

https://fireship.io/courses/react-next-firebase/admin-forms/

utterances-bot avatar Aug 10 '22 02:08 utterances-bot

If you are getting any errors related to useForm or path.split is not a function. A new format is required for the react hooks.

you must create the errors hook from the formstate property and you much also change the way you use the register hook.

const {
    register,
    handleSubmit,
    reset,
    watch,
    formState: { errors },
    formState,
  } = useForm({
    defaultValues,
    mode: "onChange",
  });

and

<textarea
          {...register("content", {
            maxLength: { value: 30000, message: "Content is too long!" },
            minLength: { value: 10, message: "Content is too short!" },
            required: { value: true, message: "Content is required" },
          })}
        ></textarea>

JimboTron9000 avatar Aug 10 '22 02:08 JimboTron9000

Thanks, @Jimbo Jeff needs to update this

mentasuave01 avatar Aug 16 '22 13:08 mentasuave01