UNPKG

zater-cep

Version:

ZAter cep correios e via cep

23 lines (19 loc) 463 B
import ErrorCep from './ErrorCep'; class FormatCep { clean(cep) { const clenCep = cep.replace(/[^\d]+/g, ''); if (clenCep.length !== 8) throw new Error('Cep inválido', 400, 'ZTR_CEP_003'); return clenCep.replace(/[^\d]+/g, ''); } makeAddres(origin, cep, state, city, district, address) { return ({ origin, cep, state, city, district, address, }); } } export default () => new FormatCep();