0.2.2 • Published 2 years ago

@policies/grida-valid-username v0.2.2

Weekly downloads
-
License
Apache 2.0
Repository
github
Last release
2 years ago

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

0.2.1

2 years ago

0.2.0

2 years ago

0.1.9

2 years ago

0.2.2

2 years ago

0.1.0

2 years ago