Browse Source

Adding field verification in recovery password

master
GabrielTrettel 3 years ago
parent
commit
b2dda34f24
  1. 20
      src/app/screens/PasswordRecoveryScreen.js

20
src/app/screens/PasswordRecoveryScreen.js

@ -59,16 +59,32 @@ function SecQuestionPicker({ name }) {
);
}
const phoneRegex = RegExp(
/^\(?[\(]?([0-9]{2})?\)?[)\b]?([0-9]{4,5})[-. ]?([0-9]{4})$/
);
const validationSchema = Yup.object().shape({
number: Yup.string()
.matches(phoneRegex, "Número inválido")
.required("O número de telefone é obrigatório"),
secQuestion: Yup.string().required("Escolha a pergunta de segurança"),
answer: Yup.string()
.required("A resposta da pergunta de segurança é obrigatória")
.max(255),
});
export default function PasswordRecovery() {
export default function PasswordRecovery({navigation}) {
return (
<View>
<Form
validationSchema={validationSchema}
initialValues={{
number: "",
answer: "",
secQuestion: "",
}}
onSubmit={() => {
navigation.navigate("PasswordRecoveryChangePswd")
}}
>
<View style={{padding:16}}>
@ -94,7 +110,7 @@ export default function PasswordRecovery() {
</View>
<View style={{ marginTop: 24 }}>
<View style={{ marginVertical: 24 }}>
<Text style={styles.labelStyle}>Resposta*:</Text>
<FormField
name="answer"

Loading…
Cancel
Save