Se alguém precisar do código pro cpf, é só seguir a lógica:
export const normalizeCpfNumber = (value: String | undefined) => {
if (!value) return "";
return value
.replace(/[\D]/g, "")
.replace(/(\d{3})(\d)/, "$1.$2")
.replace(/(\d{3})(\d)/, "$1.$2")
.replace(/(\d{3})(\d)/, "$1-$2")
.replace(/(-\d{2})\d+?$/, "$1");
};
const cpfValue = watch("cpf");
useEffect(() => {
setValue("cpf", normalizeCpfNumber(cpfValue));
}, [cpfValue]);