Skip to content

Commit

Permalink
Add format validations (#172)
Browse files Browse the repository at this point in the history
- Add validation 'Name: Must contain more than native emojis'
- Add validation 'Description: '4-byte characters are not allowed'
  • Loading branch information
srealmoreno authored Mar 8, 2023
1 parent 3bd1f50 commit 42955c2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
18 changes: 18 additions & 0 deletions lib/label-formats.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions lib/validate-label-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ const Ajv = require('ajv');

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

const addFormats = require('./label-formats');

addFormats(ajv);

const schema = {
type: 'object',
properties: {
name: { type: 'string', maxLength: 50, },
name: { type: 'string', maxLength: 50, format: 'must contain more than native emoji' },
color: { type: 'string', pattern: '^[a-fA-F0-9]{6}$' },
description: { type: 'string', maxLength: 100 },
description: { type: 'string', maxLength: 100, format: 'doesn\'t accept 4-byte Unicode' },
delete: { type: 'boolean', default: false },
aliases: {
type: 'array',
items: { type: 'string', maxLength: 50 }
items: { type: 'string', maxLength: 50, format: 'must contain more than native emoji' }
},
},
required: ['name'],
Expand Down

0 comments on commit 42955c2

Please sign in to comment.