Each field has metadata associated with it, the meta property returned from useField contains information about the field:. I dont know the keys beforehand. Typescript Dynamic object keys (map) - githubmemory ; touched: If the field was touched, can be updated with setTouched on … In addition to this, you will also learn how to set up and manage a CRM using Sanity as well as reading and writing data to a Sanity hosted CRM using GROQ. Now that we can extend our form data, we'll create a function to actually create the Yup schema based on this data. gammon … Thank you! How to validate an object with a key inside it in Yup Validation. const schema = object ({//object keys for validation go here}); So if we were to do a required name, and email our validation would look something like this. 19. const schema = object ({//object keys for validation go here}); So if we were to do a required name, and email our validation would look something like this. Note that we feed the generic with Asserts<>, which is exported by yup. Schema are comprised of parsing actions (transforms) as well as assertions (tests) about the input value. yup validate object with dynamic keys. You start by defining a schema. React state validation hook using Yup | Sandip Mane This library helps with validation of any kind, including forms. dynamically validate To get the actual errors you'll need to use the validateSync in combination with a try/catch. Step 3: Creating our dynamic schema. Thanks. of ( CarSchema ) ; Create a final schema that picks the right schema based on the value that's being validated: I know I should use lazy but I don't understand how. Our validation hook gives us errors object and a function named handleFormSubmit. We'll then use the yup.lazy method to evaluate the value at runtime and adjust our validation schema. So we're using React because why not? Validation with Yup | Techzaion Blog yup validate object with dynamic keys