I am using native base's input field and am trying to validate it using Formik and Yup. However, no validation is happening so far. It doesn't show any errors even if I type alphabets.
const initialValues: FormValues = { phoneNumber: '', }; const validationSchema = phoneNumberValidationSchema; const handleSubmit = ( values: FormValues, helpers: FormikHelpers<FormValues>, ) => { console.log('Verifying'); };
This is from my return function:
<Formik initialValues={initialValues} onSubmit={handleSubmit} validationSchema={validationSchema}> {({ handleChange, handleBlur, handleSubmit, isSubmitting, values, }) => (<View><Item><Input placeholder="Phone Number" onChangeText={handleChange('phoneNumber')} onBlur={handleBlur('phoneNumber')} value={values.phoneNumber} /></Item><View ><Button rounded ><Text > Add{''}</Text></Button></View></View> )}</Formik>
Schema:
const phoneNumberValidationSchema = yup.object().shape({ phoneNumber: yup .string() .label('phoneNumber') .required('Bitte gebe deine Handynummer ein.') .matches(/^[0-9]*$/, 'Bitte nur Ziffern eingeben.'), });
What am I missing?