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 🙏

© 2026 – Pkg Stats / Ryan Hefner

block-swearword

v1.0.1

Published

Filtro de palavrões PT-BR com normalização avançada para class-validator

Readme

biblioteca-palavroes

Filtro de palavrões PT-BR com normalização avançada. Detecta ofensas mesmo com truques de evasão como espaçamento, separadores, acentos e caixa mista.

Inclui decorator @NoProfanity() para integração direta com class-validator.

Instalação

npm install biblioteca-palavroes

Uso Básico

import { ProfanityFilter } from 'biblioteca-palavroes';

const filter = new ProfanityFilter();

filter.hasProfanity('bom dia');           // false
filter.hasProfanity('vai tomar no cu');   // true
filter.hasProfanity('V;a;i;t;o;m;a;r');  // true (separadores removidos)
filter.hasProfanity('P U T A');           // true (espaços removidos)
filter.hasProfanity('Arrômbadó');         // true (acentos normalizados)

filter.findProfanities('seu idiota');     // ['idiota']

Normalização

A biblioteca aplica 3 etapas antes de comparar com o dicionário:

  1. LowercaseCARALHOcaralho
  2. Strip acentos (NFD) — Arrômbadóarrombado
  3. Remove tudo que não é letraV;a;i t.o.m.a.rvaitormar

Isso impede evasões como:

| Tentativa | Normalizado | Detectado? | |-----------|-------------|------------| | p.u.t.a | puta | ✅ | | V a i t o m a r n o c u | vaitormarnocu | ✅ | | C-a-R-a-L-h-O | caralho | ✅ | | p_u_t_a | puta | ✅ | | VTNC | vtnc | ✅ |

Decorator para class-validator

import { NoProfanity } from 'biblioteca-palavroes';

class CreateUserDto {
  @NoProfanity({ message: 'O nome contém linguagem inadequada.' })
  name: string;
}

Rejeita automaticamente inputs ofensivos na camada de validação do NestJS/class-validator.

Palavras customizadas

Você pode adicionar palavras extras ao dicionário padrão:

const filter = new ProfanityFilter(['palavraCustom1', 'palavraCustom2']);

filter.hasProfanity('isso é palavraCustom1'); // true

Dicionário

O dicionário padrão está em word-list.json na raiz do pacote. Contém 400+ termos ofensivos em PT-BR incluindo:

  • Palavrões diretos
  • Siglas (vsfd, vtnc, tnc)
  • Variações regionais
  • Termos pejorativos

Para contribuir com novos termos, basta adicionar ao arquivo word-list.json.

API

ProfanityFilter

new ProfanityFilter(extraWords?: string[])

| Método | Retorno | Descrição | |--------|---------|-----------| | hasProfanity(text) | boolean | true se encontrar algum palavrão | | findProfanities(text) | string[] | Lista de palavrões encontrados |

@NoProfanity(options?)

Decorator para class-validator. Aceita ValidationOptions padrão.

Requisitos

  • Node.js >= 18
  • class-validator >= 0.14.0 (peer dependency, apenas se usar o decorator)

Licença

MIT