Added label validators (#2078)

* Added label validators

* Updated version
main
Boris Sekachev 6 years ago committed by GitHub
parent 1c1baeb46c
commit 1fdf10032a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,6 @@
{
"name": "cvat-ui",
"version": "1.8.1",
"version": "1.8.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

@ -1,6 +1,6 @@
{
"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}`);

Loading…
Cancel
Save