npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

valid-email.ts

v1.1.0

Published

Validador de email em TypeScript com TLDs, DNS, SMTP e descartáveis.

Readme

📧 valid-email.ts

npm version

Build

Coverage

Uma biblioteca TypeScript-first para validação de emails, incluindo:

  • Validação de formato (RFC)
  • Normalização automática (trim + lowercase)
  • Regras de tamanho (RFC: 64/255/254)
  • Verificação de TLDs (lista oficial IANA, com cache em memória)
  • Bloqueio de domínios descartáveis
  • Checagem de DNS (MX records)
  • Deep Check SMTP (opcional, best effort)
  • Suporte a múltiplos idiomas (inglês e português)

🚀 Instalação

npm  install  valid-email.ts

ou com yarn:

yarn  add  valid-email.ts

🛠️ Uso básico

import { validate } from "valid-email.ts";

const email = "[email protected]";
const result = await validate(email);

console.log(result);

Saída:

{
  "email": "[email protected]",
  "user": "test",
  "domain": "gmail.com",
  "status": "valid",
  "reasonCode": "VALID",
  "reason": "Email is valid",
  "disposable": false
}

⚙️ Opções de validação

export interface ValidationOptions {
  checkDNS?: boolean; // padrão: true - valida MX records
  deepCheckSMTP?: boolean; // padrão: false - conecta via SMTP (lento e opcional)
  allowDisposable?: boolean; // padrão: false - bloqueia descartáveis
  checkTLD?: boolean; // padrão: true - valida TLDs oficiais IANA
  lang?: "en" | "pt"; // padrão: "en" - seleciona idioma
  customMessages?: ValidationMessages; // sobrescreve mensagens padrão
}

Exemplo:

await validate("[email protected]", { allowDisposable: true });
// retorna como válido, mesmo sendo descartável

📦 Validação em lote

import { validateMany } from "valid-email.ts";

const emails = ["[email protected]", "[email protected]", "c@invalid"];
const results = await validateMany(emails);

console.log(results);

📑 Códigos de retorno (reasonCode)

| Code | Descrição |

|-----------------|----------------------------------------|

| MISSING_AT | Email não contém @ ou contém mais de um |

| MISSING_USER | Não há usuário antes do @ |

| MISSING_DOMAIN| Domínio inválido ou sem . |

| TOO_LONG | Ultrapassa limite de tamanho RFC |

| INVALID_FORMAT| Regex básica falhou |

| INVALID_TLD | TLD não está na lista oficial da IANA |

| DISPOSABLE | Domínio descartável detectado |

| NO_MX | Domínio sem MX records válidos |

| SMTP_FAIL | SMTP check falhou (best effort) |

| VALID | Email válido |


🌍 Configurações globais

Você pode definir defaults para todas as chamadas:

import { setDefaultOptions } from "valid-email.ts";

setDefaultOptions({
  allowDisposable: true,
  checkDNS: false,
});

🧪 Testes

Rodar com Vitest:

npm  run  test
npm  run  test:coverage

📄 Licença

MIT © 2025 Tiago Dias Laureano


🤝 Contribuindo

Pull Requests são bem-vindos!

  • Fork o repositório

  • Crie uma branch: git checkout -b feature/nova-feature

  • Faça commit: git commit -m 'feat: nova feature'

  • Envie PR 🚀