+
+
+
+
Nenhum imóvel encontrado
+
+ Não foram encontrados imóveis cadastrados para o
+ {{ modoConsulta === 'documento' ? 'documento informado' : 'número de inscrição informado' }}.
+ Verifique os dados e tente novamente.
+
+
{{ imoveis.length }} imóveis encontrados — selecione um
diff --git a/src/utils/formatador.js b/src/utils/formatador.js
index cf2ec8d..c0360ea 100644
--- a/src/utils/formatador.js
+++ b/src/utils/formatador.js
@@ -47,3 +47,30 @@ export function abrirPdf(buf) {
}
export { formatarMoeda, baixarPdf }
+
+export function validarCpf(cpf) {
+ const d = String(cpf).replace(/\D/g, '')
+ if (d.length !== 11 || /^(\d)\1{10}$/.test(d)) return false
+ const calc = (len) => {
+ let sum = 0
+ for (let i = 0; i < len; i++) sum += parseInt(d[i]) * (len + 1 - i)
+ const r = sum % 11
+ return r < 2 ? 0 : 11 - r
+ }
+ return calc(9) === parseInt(d[9]) && calc(10) === parseInt(d[10])
+}
+
+export function validarCnpj(cnpj) {
+ const d = String(cnpj).replace(/\D/g, '')
+ if (d.length !== 14 || /^(\d)\1{13}$/.test(d)) return false
+ const calc = (len) => {
+ const weights = len === 12
+ ? [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
+ : [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
+ let sum = 0
+ for (let i = 0; i < len; i++) sum += parseInt(d[i]) * weights[i]
+ const r = sum % 11
+ return r < 2 ? 0 : 11 - r
+ }
+ return calc(12) === parseInt(d[12]) && calc(13) === parseInt(d[13])
+}