# validate-github-label-name

> Check if a given string is a valid Github issue label name

Latest version **1.0.0** (published 2017-01-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install validate-github-label-name
pnpm add validate-github-label-name
yarn add validate-github-label-name
bun add validate-github-label-name
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-01-16 |
| First published | 2017-01-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Shinnosuke Watanabe |
| Maintainers | shinnn |
| Keywords | github, label, issue, string, check, test, validate, validation, validity, if |

## Links

- npm: https://www.npmjs.com/package/validate-github-label-name
- Repository: https://github.com/shinnn/validate-github-label-name
- Homepage: https://github.com/shinnn/validate-github-label-name#readme
- Issues: https://github.com/shinnn/validate-github-label-name/issues
- npm.io page: https://npm.io/package/validate-github-label-name

## Dependencies (4)

- [append-type](https://npm.io/package/append-type.md) ^1.0.0
- [arr-indexes-of](https://npm.io/package/arr-indexes-of.md) ^1.0.1
- [indexed-filter](https://npm.io/package/indexed-filter.md) ^1.0.0
- [array-to-sentence](https://npm.io/package/array-to-sentence.md) ^1.1.0

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2017-01-16
- 0.0.0 — 2017-01-16

## README

# validate-github-label-name

[![NPM version](https://img.shields.io/npm/v/validate-github-label-name.svg)](https://www.npmjs.com/package/validate-github-label-name)
[![Bower version](https://img.shields.io/bower/v/validate-github-label-name.svg)](https://github.com/shinnn/validate-github-label-name/releases)
[![Build Status](https://travis-ci.org/shinnn/validate-github-label-name.svg?branch=master)](https://travis-ci.org/shinnn/validate-github-label-name)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/validate-github-label-name.svg)](https://coveralls.io/r/shinnn/validate-github-label-name)

Check if a given string is a valid [Github issue label](https://help.github.com/articles/creating-and-editing-labels-for-issues-and-pull-requests/) name

```javascript
import validateGithubLabelName from 'validate-github-label-name';

const result = validateGithubLabelName('label🍕name🍔\n');
console.log(result.formatted);
```

```
Invalid issue label 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

### [npm](https://www.npmjs.com/)

```
npm install validate-github-label-name
```

### [bower](https://bower.io/)

```
bower install validate-github-label-name
```

## API

### validateGithubLabelName(*str*)

*str*: `String` (Github issue label name)  
Return: `Object`

The returned object has the following properties:

#### valid

Type: `Boolean`

Whether the string can be used as a Github issue label name.

#### reasons

Type: `Array<Object>`

Reasons why the given name is not valid. `[]` if the string is a valid label name.

##### reason[].message

Type: `String`

The human-readable description of the reason.

##### reason[].positions

Type: `Array<Number>`

The positions in the string where invalid characters are found.

#### formatted

Type: `String`

The prettily formatted validation message.

```javascript
import validateGithubLabelName from 'validate-github-label-name';

const result0 = validateGithubLabelName('enhancement');
result0.valid; //=> true
result0.reasons; //=> []
result0.formatted; //=> ''

const result1 = validateGithubLabelName('abc\n𠮷\ndef');
result1.valid;
//=> true

result1.reasons;
/* => [
  {
    positions: [3, 5],
    message: 'Label name cannot have linebreaks.'
  },
  {
    positions: [4],
    message: 'Invalid character: "𠮷". Label name cannot have Unicode characters above 0xFFFF.'
  }
] */

result1.formatted;
//=> 'Invalid issue label name "abc\\n𠮷\\ndef":\nat 3,5: Label name cannot have ...'
```

## License

Copyright (c) 2017 [Shinnosuke Watanabe](https://github.com/shinnn)

Licensed under [the MIT License](./LICENSE).

---
_Source: https://npm.io/package/validate-github-label-name · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
