forked from M3-Academy/desafio-react-e-typescript
refactor: organizando arquivos do yup em uma pasta
This commit is contained in:
parent
fdb349cb86
commit
be31f120e6
@ -1,13 +1,13 @@
|
||||
import styles from "./styles/Footer.module.scss";
|
||||
import { Formik, Field, Form } from "formik";
|
||||
import schema from "./schema";
|
||||
import schema from "../../schema/NewsletterSchema";
|
||||
|
||||
interface NewsletterArea {
|
||||
email: string;
|
||||
newsletteremail: string;
|
||||
}
|
||||
|
||||
const initialValues = {
|
||||
email: "",
|
||||
newsletteremail: "",
|
||||
};
|
||||
|
||||
const Newsletter = () => {
|
||||
@ -23,7 +23,7 @@ const Newsletter = () => {
|
||||
assine nossa newsletter
|
||||
</h3>
|
||||
<div className={styles["Newsletter__Content__Block__Register"]}>
|
||||
<Field type="text" placeholder="E-mail" name="email" />
|
||||
<Field type="text" placeholder="E-mail" name="newsletteremail" />
|
||||
<button type="submit" disabled={!isValid}>Enviar</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Formik, Field, Form } from "formik";
|
||||
import schema from "../schema";
|
||||
import schema from "../../../schema/FormSchema";
|
||||
import styles from "../styles/Main.module.scss";
|
||||
import { FormField } from "../Contato/FormContentField/FormContentField";
|
||||
import { useState } from "react";
|
||||
|
@ -1,8 +1,8 @@
|
||||
import * as Yup from 'yup';
|
||||
|
||||
const email =
|
||||
const newsletteremail =
|
||||
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
|
||||
export default Yup.object().shape({
|
||||
email: Yup.string().email().matches(email).required(),
|
||||
newsletteremail: Yup.string().email().matches(newsletteremail).required(),
|
||||
});
|
Loading…
Reference in New Issue
Block a user