Skip to content

Commit 42955c2

Browse files
authored
Add format validations (#172)
- Add validation 'Name: Must contain more than native emojis' - Add validation 'Description: '4-byte characters are not allowed'
1 parent 3bd1f50 commit 42955c2

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

lib/label-formats.js

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/validate-label-format.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@ const Ajv = require('ajv');
44

55
const ajv = new Ajv({ allErrors: true });
66

7+
const addFormats = require('./label-formats');
8+
9+
addFormats(ajv);
10+
711
const schema = {
812
type: 'object',
913
properties: {
10-
name: { type: 'string', maxLength: 50, },
14+
name: { type: 'string', maxLength: 50, format: 'must contain more than native emoji' },
1115
color: { type: 'string', pattern: '^[a-fA-F0-9]{6}$' },
12-
description: { type: 'string', maxLength: 100 },
16+
description: { type: 'string', maxLength: 100, format: 'doesn\'t accept 4-byte Unicode' },
1317
delete: { type: 'boolean', default: false },
1418
aliases: {
1519
type: 'array',
16-
items: { type: 'string', maxLength: 50 }
20+
items: { type: 'string', maxLength: 50, format: 'must contain more than native emoji' }
1721
},
1822
},
1923
required: ['name'],

0 commit comments

Comments
 (0)