score:0
Accepted answer
you can add a validator directly to the field (in its validate property) and this will be applied to the specific field element in the array. for example with a validator called 'required' as in this example
const required = value => (value ? undefined : "required");
then the field will look like this with the ability to access the metadata with any validation errors
<field
name={`${name}.firstname`}
validate={ required }
render={({ input, meta }) => (
<div>
<input {...input} />
{meta.touched && meta.error && <span>{meta.error}</span>}
</div>
)}
/>
working example :
score:1
you can add validation before submit and after submit like this https://codesandbox.io/s/8xkn4r10m8
Source: stackoverflow.com
Related Query
- How to format the value of a checkbox Field using React Final Form Field Array?
- How can I validate array field in React Hook Form with the useFieldArray hook?
- React : How can I set the error messages?
- How to set a general onchange for the dynamic form fields coming from api in react js.?
- How to sort the date form to latest to the oldest in array of objects react js
- React - How to use the current state value as a variable so i can set as a index inside an array
- How change the format of checkbox in react final form
- How to stop displaying error when data inside text input was set like this: value={value} React Hook Form
- How to set the error in the array react-final-form
- How to set the initial state value after fetching data to update a form in react
- How to set state in react whith the content at a certain index from an array
- React Hook error in array handing in useEffect() and setState does not set the state
- How to filter the data array student based on the room using react hook form
- How to set the DefaultRoute to another Route in React Router
- How do I add validation to the form in my React component?
- How to set/change Field value from external user action 🏁 React Final Form
- How to set the height of button in React Native Android
- how to set state array using react hooks
- How to set the width of a React component during test?
- How to TEST async calls made in componentDidMount that set the state of React Component
- How do you set the Typescript type for useRef hook in React Native?
- How do I add an item to the front of a state array in React
- How to set multiple values at once in react hook form using Typescript
- How to use setState() in React to blank/clear the value of an array
- How can I set the content offset of a FlatList in React Native?
- With a Styled-Components, how to set an array of colors outside of the Styled Component?
- How to debug react in vs code ? Error break point set but not yet bound
- How to rerun validation on submit in React Final Form
- How can I set the source of an image dynamically in React native?
- How can I programmatically set the user details for Launch Darkly in my react app
More Query from same tag
- indexOf() not working as expected, function keeps adding duplicates - React
- Redirect after POST using reactjs
- Passing a method down two levels
- Specify variable type passing function as a prop
- block a button until the user accepts the geolocation react.js
- How do I create an array of unique field values in React with data from Firestore?
- How can I target other css class in another class?
- save values of arrays inside a state from different input fields
- Image and text side by side in div, want to shrink image on resize
- I get an Error from React: Maximum update depth exceeded
- how to convert virtual DOM to an real DOM Element without render?
- Only else statement renders in react JS
- Using In App Browser cordova plugin with typescript
- How to initialize state with a function returning localstored value on window's load event on Nextjs?
- Component output by pressing the ReactJS button using the props
- How to reset RTKQuery mutation state back to `uninitiated` inside a thunk?
- Looping dynamic server response in React render
- why my useReducer function is not working.when I use it The page show but function is not working
- How to modify dom elements programmatically in reactjs?
- How to get key from object in map function?
- Destructuring object and ignore one of the results
- Jest - Mocking a React Component's dependency which returns a Promise
- Using p5 library inside react project
- Find lowest value in array and add class
- How to convert a json encoded php variable to a JavaScript JSON object in the same file
- React Adding Background Image Behind Component
- React imported library throws error: cannot convert undefined or null to object
- How do you pass a parameter to defineMessages in react-intl?
- MobX Mutability vs Immutability
- Getting checkbox value in react onchek