0
all good? I have a Validator with Yup, and a formik, but somehow onsubmit is not called, when I click the button, I already checked in the Debugger if something is called and nothing :(
This is my Validator:
const validator = yup.object().shape({
currentPassword: yup
.string()
.min(8, 'Sua senha deve conter pelo menos 8 caracteres')
.required('Preencha uma senha válida'),
newPassword: yup
.string()
.min(8, 'Sua senha deve conter pelo menos 8 caracteres')
.required('Preencha uma senha válida'),
confirmPassword: yup
.string()
.min(8, 'Sua senha deve conter pelo menos 8 caracteres')
.oneOf([yup.ref('newPassword'), null], 'As senhas digitadas não são iguais')
.required('Confirme sua senha')
});
this is the formik
<Formik
initialValues={{
currentPassword: this.state.currentPassword,
newPassword: this.state.newPassword,
confirmPassword: this.state.confirmPassword,
}}
validationSchema={validator}
onSubmit={this.onSubmit}>
{({
handleChange,
handleBlur,
errors,
touched,
handleSubmit,
values,
}) => (
<>
<TextInput
formikKey="currentPassword"
label={'Digite sua senha atual'}
containerStyles={Sheet.textIpunt}
onChangeText={handleChange('currentPassword')}
onBlur={handleBlur('currentPassword')}
errorMessage={touched.currentPassword && errors.currentPassword}
isSecure={true}
show={this.state.passwordVisibility}
onChangeVisibility={this.passwordVisibility}
autoCapitalize={'none'}
value={values.currentPassword}
/>
<TextInput
formikKey="newPassword"
label={'Digite sua nova senha'}
containerStyles={Sheet.textIpunt}
onChangeText={handleChange('newPassword')}
onBlur={handleBlur('newPassword')}
errorMessage={touched.newPassword && errors.newPassword}
show={this.state.passwordVisibility}
onChangeVisibility={this.passwordVisibility}
isSecure={true}
autoCapitalize={'none'}
value={values.newPassword}
/>
<TextInput
formikKey="confirmPassword"
label={'Confirme a nova senha'}
containerStyles={Sheet.textIpunt}
onChangeText={handleChange('confirmPassword')}
onBlur={handleBlur('confirmPassword')}
errorMessage={touched.confirmPassword && errors.confirmPassword}
show={this.state.passwordVisibility}
onChangeVisibility={this.passwordVisibility}
isSecure={true}
autoCapitalize={'none'}
value={values.confirmPassword}
/>
<AppButton label={'Trocar Senha'} onPress={handleSubmit} />
{/* <ButtonLoading title="Alterar Senha" styleText={Styles.ButtonChangePasswordTitle} style={Styles.ButtonChangePassword} loading={loading}
onPress={handleSubmit}>
</ButtonLoading> */}
</>
)}
</Formik>