Skip to content

Input validation using yup #2132

Answered by abdhalees
manuel-subredu asked this question in Q&A
Discussion options

You must be logged in to vote

Hello Manuel,

from your code it looks like you're using react-hook-form, instead of using register you can use controller, so your component will look like this:

import  Input  from "@cloudscape-design/components/input"
import  Button  from "@cloudscape-design/components/button"
import  FormField  from "@cloudscape-design/components/form-field"
import { useForm, Controller } from "react-hook-form"


function App() {
  const { handleSubmit, control } = useForm<FormValues>()


  return (
    <form onSubmit={handleSubmit((data) => console.log(data))}>
    <FormField label={label}   errorText={errors.name && <p>{errors.name.message}</p>}>
      <Controller
        control={control}
        na…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Al-Dani
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