@policies/grida-valid-username
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

Username validation

yarn add @policies/grida-valid-username
import { prevalidate, flat } from "@policies/grida-valid-username";

const username = "Some extraord!nary Us3rnamé";

prevalidate(username); // -> valid: false, type: "invalid-characters"
flat(username); // -> some-extraordnary-us3rname
prevalidate(flat(username)); // -> valid: true

Invalidations

export type InvalidationType =
  | "already-taken"
  | "too-long"
  | "blank-space"
  | "start-with-hyphen"
  | "end-with-hyphen"
  | "consecutive-hyphens"
  | "invalid-character"
  | "unknown";

The regex

/^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}$/i;

Blocked

Bad words


Readme

Keywords

none

Package Sidebar

Install

npm i @policies/grida-valid-username

Weekly Downloads

8

Version

0.2.2

License

Apache 2.0

Unpacked Size

57.3 kB

Total Files

7

Last publish

Collaborators

  • softmarshmallow