Adding validations for dynamic data in react
See original GitHub issueUsing react formal with my schema statically defined (and reused):
export const AddressSchema = yup.object({
category: string.nullable(),
full_name: string.nullable(),
address1: string.required(),
address2: string.nullable(),
city: string.required().min(2).max(30),
state_code: string.required().min(2).max(2),
postal_code: string.required().min(5).max(13),
country_code: string.default('US').required().min(2).max(3),
default_billing: boolean,
default_shipping: boolean
})
export const ContactSchema = yup.object({
first_name: string.required(),
last_name: string.required(),
email: string.required().email(),
mobile_phone: string.required().phone(),
work_phone: string.phone().nullable(),
home_phone: string.phone().nullable(),
addresses: edges(AddressSchema).min(1)
})
I have a dynamic dataset provided that gives me viable subregions (or states). How can I tack on a dynamic test to state_code
inside a render
or componentWillMount
?
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
How to validate on dynamic input fields using react
I have displayed some dynamic input fields for name input from an array and trying to add validations on it. Expectations:.
Read more >How to Add Form Validation to React Dynamic Forms
To build the Yup schema, we first add the static fields to , from and subject for validation. Then we loop through the...
Read more >Dynamic field validation in Reactjs | by Unisha Acharya
In this article, we will be validating the dynamic fields. Let's dive into the code. Now, moving forward from the point where we…...
Read more >Create Dynamic Forms in React Using React Hook Forms
This article is about creating dynamic forms in React using React Hook Form and performing validation on data entered in form fields.
Read more >Dynamic Form Validations with React Hooks - Medium
Dynamic Form Validations with React Hooks · First we loop through each configuration in the configuration list · Clone the configuration which is ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Working state validation - dependent on context and other field:
Ugh - can’t use arrow functions here if I want
this
. No problem, just confusion.