You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been working on a project where a person is supposed to select a couple of radio buttons which their value gets put in an array.
That works perfectly however I want to validate the final array to make sure that there aren't any invalid values in the array.
I already have an array with all the correct values but I don't know how to make yup check if the array doesn't contain strings that don't match the pre-defined array.
exportconstcreateAPIKeySchema=yup.object().shape({name: yup.string().min(4,"Name can't be less than 4 characters.").max(32,"Name can't be more than 32 characters.").required(),permissions: yup.array().of(yup.string()).defined().required().min(1,"You must pick at least one option."),});
Any help would be appreciated, thanks!
The text was updated successfully, but these errors were encountered:
import*asyupfrom"yup";import{isPermission}from"../api-tokens/index";exportconstcreateAPIKeySchema=yup.object().shape({name: yup.string().min(4,"Name can't be less than 4 characters.").max(32,"Name can't be more than 32 characters.").required(),permissions: yup.array().of(yup.string().test("valid","This is not a valid permission!",(val)=>{if(isPermission(val))returntrue;returnfalse;})).defined().required().min(1,"You must pick at least one option."),});
Hey everyone,
I have been working on a project where a person is supposed to select a couple of radio buttons which their value gets put in an array.
That works perfectly however I want to validate the final array to make sure that there aren't any invalid values in the array.
I already have an array with all the correct values but I don't know how to make yup check if the array doesn't contain strings that don't match the pre-defined array.
This is my yup schema:
Any help would be appreciated, thanks!
The text was updated successfully, but these errors were encountered: