Skip to content

shinnn/assert-valid-github-label-name

Repository files navigation

assert-valid-github-label-name

npm version Build Status Coverage Status

Assert a given string is a valid Github issue label name

import assertValidGithubLabelName from 'assert-valid-github-label-name';

assertValidGithubLabelName('label🍕name🍔\n');
/Users/shinnn/node_modules/assert-valid-github-label-name/index.js:27
  throw new Error(
  ^

Error: Expected a valid Github issue label name, but got an invalid name "label🍕name🍔\n":
at 5,10: Invalid characters: "🍕" and "🍔". Label name cannot have Unicode characters above 0xFFFF.
at 11: Label name cannot have linebreaks.

Installation

Use npm.

npm install assert-valid-github-label-name

API

import assertValidGithubLabelName from 'assert-valid-github-label-name';

assertValidGithubLabelName(str)

str: string (Github issue label name)

It throws an error when the given string is not a valid Github issue label name.

// doesn't throw
assertValidGithubLabelName('foo');
assertValidGithubLabelName('bar baz');

// throws an error
assertValidGithubLabelName('😄');
assertValidGithubLabelName('𠮷');
assertValidGithubLabelName('ab\ncd');
assertValidGithubLabelName(' ');
assertValidGithubLabelName('');

License

ISC License © 2018 Shinnosuke Watanabe

About

Assert a given string is a valid Github issue label name

Resources

License

Stars

Watchers

Forks

Packages

No packages published