Get Formik Validation Current Year and Up
问题 I need to get the validation using Formik that input should only be currentYear and up. const currentYear = new Date().getFullYear(); expiryYear: yup .string() .required('Select expiry year') .min(4, `Invalid year format (Example: ${currentYear + 4})`) .max(4, `Invalid year format (Example: ${currentYear + 4})`) .when('startDate', (currentYear, schema) => currentYear && schema.min(currentYear)), 回答1: Try this please: yup.date() .min(new Date().getFullYear(), 'Year must be current year or