@@ -2,43 +2,33 @@ import Ajv from 'ajv/dist/jtd.js'
22
33const ajv = new Ajv ( )
44
5- const branchSchema = /** @type {const } */ ( {
5+ const fullProductNameSchema = /** @type {const } */ ( {
66 additionalProperties : true ,
77 optionalProperties : {
8- branches : {
9- elements : {
10- additionalProperties : true ,
11- properties : { } ,
12- } ,
13- } ,
14- product : {
8+ product_identification_helper : {
159 additionalProperties : true ,
1610 optionalProperties : {
17- product_identification_helper : {
18- additionalProperties : true ,
19- optionalProperties : {
20- serial_numbers : { elements : { type : 'string' } } ,
21- } ,
22- } ,
11+ serial_numbers : { elements : { type : 'string' } } ,
2312 } ,
2413 } ,
2514 } ,
2615} )
2716
28- const validateBranch = ajv . compile ( branchSchema )
29-
30- const fullProductNameSchema = /** @type {const } */ ( {
17+ const branchSchema = /** @type {const } */ ( {
3118 additionalProperties : true ,
3219 optionalProperties : {
33- product_identification_helper : {
34- additionalProperties : true ,
35- optionalProperties : {
36- serial_numbers : { elements : { type : 'string' } } ,
20+ branches : {
21+ elements : {
22+ additionalProperties : true ,
23+ properties : { } ,
3724 } ,
3825 } ,
26+ product : fullProductNameSchema ,
3927 } ,
4028} )
4129
30+ const validateBranch = ajv . compile ( branchSchema )
31+
4232/*
4333 This is the jtd schema that needs to match the input document so that the
4434 test is activated. If this schema doesn't match, it normally means that the input
@@ -105,8 +95,8 @@ export function checkSerialNumbers(serialNumbers) {
10595 const invalidNumbers = [ ]
10696 if ( serialNumbers ) {
10797 for ( let i = 0 ; i < serialNumbers . length ; i ++ ) {
108- const modelNumber = serialNumbers [ i ]
109- if ( containMultipleUnescapedStars ( modelNumber ) ) {
98+ const serialNumber = serialNumbers [ i ]
99+ if ( containMultipleUnescapedStars ( serialNumber ) ) {
110100 invalidNumbers . push ( '' + i )
111101 }
112102 }
0 commit comments