validate-github-label-name
Check if a given string is a valid Github issue label name
; const result = ;console;
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
npm install validate-github-label-name
bower
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.
; const result0 = ;result0valid; //=> trueresult0reasons; //=> []result0formatted; //=> '' const result1 = ;result1valid;//=> true result1reasons;/* => [ { positions: [3, 5], message: 'Label name cannot have linebreaks.' }, { positions: [4], message: 'Invalid character: "𠮷". Label name cannot have Unicode characters above 0xFFFF.' }] */ result1formatted;//=> 'Invalid issue label name "abc\\n𠮷\\ndef":\nat 3,5: Label name cannot have ...'
License
Copyright (c) 2017 Shinnosuke Watanabe
Licensed under the MIT License.