yup

React-select with Formik not updating select field but does everything else

懵懂的女人 提交于 2019-12-11 14:39:40
问题 React-Select with Formik is not loading the selected value in select componenet but I'm able to get values on form submission and validation also works with Yup Here is a codesandbox demo for the same - https://codesandbox.io/s/wild-violet-fr9re https://codesandbox.io/embed/wild-violet-fr9re?fontsize=14 import React, { Component } from "react"; import { Formik, Form, ErrorMessage } from "formik"; import * as Yup from "yup"; import Select from "react-select"; const debug = true; class

Conditional Validation in Yup

拈花ヽ惹草 提交于 2019-12-04 16:51:20
问题 I have an email field that only gets shown if a checkbox is selected (boolean value is true ). When the form get submitted, I only what this field to be required if the checkbox is checked (boolean is true). This is what I've tried so far: const validationSchema = yup.object().shape({ email: yup .string() .email() .label('Email') .when('showEmail', { is: true, then: yup.string().required('Must enter email address'), }), }) I've tried several other variations, but I get errors from Formik and

Conditional Validation in Yup

孤人 提交于 2019-12-03 09:58:44
I have an email field that only gets shown if a checkbox is selected (boolean value is true ). When the form get submitted, I only what this field to be required if the checkbox is checked (boolean is true). This is what I've tried so far: const validationSchema = yup.object().shape({ email: yup .string() .email() .label('Email') .when('showEmail', { is: true, then: yup.string().required('Must enter email address'), }), }) I've tried several other variations, but I get errors from Formik and Yup: Uncaught (in promise) TypeError: Cannot read property 'length' of undefined at yupToFormErrors