
javascript - Conditional Validation in Yup - Stack Overflow
Totally agree with @João Cunha's answer. Just a supplement for the use case of Radio button. When we use radio button as condition, we can check value of string instead of boolean. e.g. is: 'Phone'
reactjs - How to use yup with react hook form? - Stack Overflow
Feb 13, 2021 · Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question.Provide details and share your research!
Validation using Yup to check string or number length
Apr 17, 2018 · @Tamlyn's answer covers the length validation aspect of the question quite well.. In the case of a zip code, you could use a regex to enforce the length and limit to numeral values within the Yup.string() (you wouldn't want to use a Yup.number() type as it wouldn't support zip codes starting with a zero 0####)
node.js - How to validate enums in yup - Stack Overflow
Jan 21, 2020 · this is a sample of my validations - I'm using object.shape method of the yup: export const deleteCityValidation = yup.object().shape({ id: yup.string() }); looking for a way to validate an input field that should only have a value from a set of enums any help is appreciated . is it possible to use yup.arrays to validate enums ?
How can I make a yup number accept nullable values?
Aug 3, 2020 · I have the following yup check: nrOfApples: yup.number().min(0).max(999), And right now if I leave the field blank, it validates as false. Is there any way to make yup.number() accept empty values? I have tried: yup.number().nullable() But it doesn't seem to work. Any ideas on how I can make such thing happen?
Yup package npm - abortEarly doesn't work as expected
Apr 2, 2024 · Do I commit the package-lock.json file created by npm 5? 2976 What's the difference between dependencies, devDependencies, and peerDependencies in NPM package.json file?
How to customize yup validation messages? - Stack Overflow
Dec 26, 2020 · Most answers I have seen customize yup validation messages when defining a schema, e.g. const personSchema = yup.object().shape({ firstName: yup.string().required('First name is a required field'), lastName: yup.string().required('Last name is a required field'), }); But what if I want to customize the default validation message itself?
javascript - Yup is not validating a checkbox when the user clicks …
You can also handle the condition explicitly using the test function from yup. const schema = yup.object().shape({ tandc: yup .boolean() .test( "is-true", "You must accept the terms and conditions", (value) => value === true ), }) A bit overkill, but still useful for advanced computations.
reactjs - Validating file presence with YUP - Stack Overflow
Sep 20, 2018 · I'm using Yup to validate my form. In one of my form, I want to validate that one <input type="file" />; has a file.
Automatically trim white spaces with Yup and Formik
Feb 26, 2020 · I am using a Formik React Form and Yup validation defined on a schema: export const Contact = yup.object<IContact>().shape({ contactName: yup .string() .trim('The contact name cannot include leading and trailing spaces') .strict(true) .min(1, 'The contact name needs to be at least 1 char') .max(512, 'The contact name cannot exceed 512 char') .required('The contact Name is required'), });