Commit c8f80ae7 authored by Henrique Barbosa's avatar Henrique Barbosa
Browse files

fix: Change error message

parent fce7327c
import { firstLetterUpperCase } from "./string";
export type Error = {
fieldName: string;
message: string;
......@@ -11,7 +9,7 @@ export function showError(errors: Error[]) {
alert('Erro!\nEsse e-mail já foi cadastrado por outro usuário!');
}
if (error.fieldName.includes('cpf')) {
alert(`Erro!\n${firstLetterUpperCase(error.message)}!`);
alert(`Erro!\nNúmero de CPF inválido!`);
}
});
}
function firstLetterUpperCase(str: string) {
return str.replace(/^\w/, (c) => c.toUpperCase());
}
function formatCpf(event: Event) {
let value = (event.target as HTMLInputElement).value;
value = value.replace(/\D/g, '');
......@@ -11,4 +7,4 @@ function formatCpf(event: Event) {
(event.target as HTMLInputElement).value = value;
}
export { firstLetterUpperCase, formatCpf }
export { formatCpf }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment