Why this matters
Accurate identifiers reduce unlawful processing and mistaken identity under LGPD.
Validate CPF/CNPJ format and checksum server-side; reject storage of invalid identifiers and never auto-correct them. Store normalized (digits-only) representation.
Accurate identifiers reduce unlawful processing and mistaken identity under LGPD.
Side-by-side examples engineers can pattern-match during review.
const cpf = req.body.cpf; db.save({ cpf });const cpf = onlyDigits(req.body.cpf);\nif(!isValidCPF(cpf)) return res.status(422).json({ error: 'invalid_cpf' });\nstore({ cpf });if(isValidCPF(onlyDigits(cpf))) store({cpf})store({ cpf }) // no validationFrom the same buckets as this rule.