未验证 提交 1fdf1003 编写于 作者: B Boris Sekachev 提交者: GitHub

Added label validators (#2078)

* Added label validators

* Updated version
上级 1c1baeb4
{
"name": "cvat-ui",
"version": "1.8.1",
"version": "1.8.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
{
"name": "cvat-ui",
"version": "1.8.1",
"version": "1.8.2",
"description": "CVAT single-page application",
"main": "src/index.tsx",
"scripts": {
......
......@@ -44,6 +44,11 @@ function validateParsedAttribute(attr: Attribute): void {
+ `Attribute values must be an array. Got type ${typeof (attr.values)}`);
}
if (!attr.values.length) {
throw new Error(`Attribute: "${attr.name}". Attribute values array mustn't be empty`);
}
for (const value of attr.values) {
if (typeof (value) !== 'string') {
throw new Error(`Attribute: "${attr.name}". `
......@@ -62,6 +67,11 @@ export function validateParsedLabel(label: Label): void {
+ `Type of label id must be only a number or undefined. Got value ${label.id}`);
}
if (typeof (label.color) !== 'string') {
throw new Error(`Label "${label.name}". `
+ `Label color must be a string. Got ${typeof (label.color)}`);
}
if (!label.color.match(/^#[0-9a-f]{6}$|^$/)) {
throw new Error(`Label "${label.name}". `
+ `Type of label color must be only a valid color string. Got value ${label.color}`);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册