Skip to content

Fix/add field letter validation #295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/pages/CreateSupply/CreateSupply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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'),
Expand Down Expand Up @@ -197,4 +198,4 @@ const CreateSupply = () => {
);
};

export { CreateSupply };
export { CreateSupply };