From 7e159ae070653950b09bf81471ddbc95a9104e1c Mon Sep 17 00:00:00 2001 From: Giovani Carnaval Date: Wed, 22 May 2024 00:56:08 -0300 Subject: [PATCH 1/2] fix: add validation to ensure field contains at least one letter --- src/pages/CreateSupply/CreateSupply.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/CreateSupply/CreateSupply.tsx b/src/pages/CreateSupply/CreateSupply.tsx index 18fd1a3a..c2496c4d 100644 --- a/src/pages/CreateSupply/CreateSupply.tsx +++ b/src/pages/CreateSupply/CreateSupply.tsx @@ -25,6 +25,7 @@ const CreateSupply = () => { const { shelterId = '-1' } = useParams(); const { toast } = useToast(); const { data: supplyCategories, loading } = useSupplyCategories(); + const containsLetter = /[a-zA-Z]/; const { errors, @@ -46,7 +47,7 @@ const CreateSupply = () => { validateOnMount: false, validationSchema: Yup.object().shape({ shelterId: Yup.string().required('Este campo deve ser preenchido'), - name: Yup.string().required('Este campo deve ser preenchido'), + name: Yup.string().matches(containsLetter, "O campo não pode conter apenas números.").required('Este campo deve ser preenchido'), quantity: Yup.number().typeError('Insira um valor númerico').moreThan(0, 'O valor tem que ser maior do que 0').optional(), priority: Yup.string().required('Este campo deve ser preenchido'), supplyCategoryId: Yup.string().required('Este campo deve ser preenchido'), From bd676d5fb3013e69898de3cac400c7e2f80ce598 Mon Sep 17 00:00:00 2001 From: Giovani Carnaval Date: Wed, 22 May 2024 01:13:51 -0300 Subject: [PATCH 2/2] fix: add validation to ensure field contains at least one letter --- src/pages/CreateSupply/CreateSupply.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/CreateSupply/CreateSupply.tsx b/src/pages/CreateSupply/CreateSupply.tsx index c2496c4d..1b7e0fe2 100644 --- a/src/pages/CreateSupply/CreateSupply.tsx +++ b/src/pages/CreateSupply/CreateSupply.tsx @@ -198,4 +198,4 @@ const CreateSupply = () => { ); }; -export { CreateSupply }; +export { CreateSupply }; \ No newline at end of file