score:0
for handle empty array error you don't need use required()
and if you are using formik for handle with custom message use array().min(1, ' your message')
score:1
UPDATE / WARNING:
Previously only array().required()
was required to make sure there was at leas 1 item in the array. For example []
would not pass the test.
⚠️ As of version 0.31.0 (2020-11-23) the behavior of array().required()
changed! Now to make sure you have at least 1 item in the array you need to sure: array().required().min(1)
score:5
You can use .min()
:
validationSchema={Yup.object({
permissions: Yup.array().min(1)
})}
Source: stackoverflow.com
Related Query
- Yup (with formik and react) - Can't validate array length
- React Select not showing errors when validating with Formik and Yup
- React yup validation with and react-hook-form, array of different type of objects depends from one of object attribute
- Array of objects does not render fully in React and shows the array length on console that does not match with the reality
- how to validate "input type = 'date' " with Formik and Yup
- Async validation with Formik, Yup and React
- Typescript and React setting initial state with empty typed array
- Automatically trim white spaces with Yup and Formik
- Validation using Formik with Yup and React-select
- Don't Validate untouched fields in Formik and Yup on submitting if field is not empty
- How to limit the text filed length with input type number in React JS and prevent entry of E,e, -, + etc
- How to validate with Yup that in array of objects at least one of object keys has true value?
- Formik React with 2 buttons (Submit and Save) to submit form - Save button not to trigger validation
- How to validate min age with yup and moment.js?
- validate if username already exists while typing using Formik and Yup
- mapping an array of objects and changing the value with on onClick in React
- Edit an entry with Formik and Yup doesn't recognize the existing fields
- Loop through array of file urls and download each one with React
- formik + yup and validating fields that are in a child react component
- React - Combine data returned two api calls and set state of an array with these values
- Issues with this.setState and this.state while updating an array in React JS
- Validate Field in Yup based on multiple related field values with Yup.ref and .test
- Formik & Yup - How to make a schema for an array and string
- React useEffect(), fetch data with React Hooks and set the formik form
- loop through an array and show single item at a time with dynamic time duration like setTimeout or SetInterval in react js
- Yup Was Not Working With Formik and also not provide any type of error
- Validate react-input-mask length using Formik + Yup
- Add item in array with index - react redux and redux-saga
- React and Google Maps with google-maps-react, cant get to API's methods
- Can't validate react-select using Formik with Yup
More Query from same tag
- Alter a specific element in an array inside redux toolkit state
- Bottom Fixed div getting pushed up with android keyboard
- Redirect to another component after submit in react
- React Redux action is being called before init
- × typeerror: cannot destructure property 'yyy' of 'object(...)(...)' as it is undefined
- How to prevent the rerenders and improve performance (Todo example with hooks)
- React-Time-Range Only Shows Default Start Time
- Avoiding duplicate style properties when styling my JSX content?
- How do I mock a function within a functional component in Typescript?
- Arranging an Image and a Component on the same line
- Is it possible to update a context state outside of a react component?
- How to properly display message between sender and receiver in reactjs
- ReactJS: Input onChange not Updating State
- When updating the state of the search input it is always 1 input behind in react
- When I apply react router to my app, it stops showing all the content
- Remove an element from an array of objects in react js
- React js state update issue
- AXIOS Status 400 Bad Request on React Front End
- Debugging ReactJs in Chrome on page load - this and everything else is undefined when using console
- react hooks props in useEffect
- How to open new page and scroll to id leaving the URL unaffected?
- React Hooks, object state is not updating onSubmit
- Pass data from React to Sails and return value
- Is there a way to prevent getting photos randomly on Firebase Storage?
- react-scroll scrollToBottom not working when scroll to x does work
- How to properly parse a JSON and look for a key
- Issue running react-redux with webpack
- How to make a progressbar with time data?
- How do I limit fetch calls made to an endpoint service so that no more than 10 calls per second are made?
- Comparing a value from two different array of objects in React.JS