Skip to content

Instantly share code, notes, and snippets.

@hellivan
Last active May 14, 2019 05:16
Show Gist options
  • Select an option

  • Save hellivan/3331677eba2589b8cb32ef9177787dc4 to your computer and use it in GitHub Desktop.

Select an option

Save hellivan/3331677eba2589b8cb32ef9177787dc4 to your computer and use it in GitHub Desktop.
// Global structure required by validate function
const validate = {
errors: null
};
// Global formats required by validate function
const formats = {
date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/,
'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d:\d\d)$/i
};
// Function for validating data against a JSON schema. Implementation is based
// on generated validatorFunction generated by AJV library https://github.com/epoberezkin/ajv
function validateFunction(data, dataPath, parentData, parentDataProperty, rootData) {
'use strict';
var vErrors = null;
var errors = 0;
if ((data && typeof data === "object" && !Array.isArray(data))) {
if (true) {
var valid1 = true;
if (valid1) {
if (data.field2 === undefined) {
valid1 = false;
validate.errors = [{
keyword: 'required',
dataPath: (dataPath || '') + "",
schemaPath: '#/required',
params: {
missingProperty: 'field2'
},
message: 'should have required property \'field2\''
}];
return false;
} else {
var errs_1 = errors;
if (typeof data.field2 !== "string") {
validate.errors = [{
keyword: 'type',
dataPath: (dataPath || '') + '.field2',
schemaPath: '#/properties/field2/type',
params: {
type: 'string'
},
message: 'should be string'
}];
return false;
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field3;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "string") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field3',
schemaPath: '#/properties/field3/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field3',
schemaPath: '#/properties/field3/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field3',
schemaPath: '#/properties/field3/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field4;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "string") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field4',
schemaPath: '#/properties/field4/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field4',
schemaPath: '#/properties/field4/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field4',
schemaPath: '#/properties/field4/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field5;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "boolean") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field5',
schemaPath: '#/properties/field5/anyOf/0/type',
params: {
type: 'boolean'
},
message: 'should be boolean'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field5',
schemaPath: '#/properties/field5/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field5',
schemaPath: '#/properties/field5/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field6;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "string") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field6',
schemaPath: '#/properties/field6/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field6',
schemaPath: '#/properties/field6/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field6',
schemaPath: '#/properties/field6/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field7;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "string") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field7',
schemaPath: '#/properties/field7/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field7',
schemaPath: '#/properties/field7/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field7',
schemaPath: '#/properties/field7/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field8;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "string") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field8',
schemaPath: '#/properties/field8/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field8',
schemaPath: '#/properties/field8/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field8',
schemaPath: '#/properties/field8/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field9;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "string") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field9',
schemaPath: '#/properties/field9/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field9',
schemaPath: '#/properties/field9/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field9',
schemaPath: '#/properties/field9/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field10;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "string") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field10',
schemaPath: '#/properties/field10/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field10',
schemaPath: '#/properties/field10/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field10',
schemaPath: '#/properties/field10/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field11;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "number") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field11',
schemaPath: '#/properties/field11/anyOf/0/type',
params: {
type: 'number'
},
message: 'should be number'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field11',
schemaPath: '#/properties/field11/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field11',
schemaPath: '#/properties/field11/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field12;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "number") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field12',
schemaPath: '#/properties/field12/anyOf/0/type',
params: {
type: 'number'
},
message: 'should be number'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field12',
schemaPath: '#/properties/field12/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field12',
schemaPath: '#/properties/field12/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field13;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "number") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field13',
schemaPath: '#/properties/field13/anyOf/0/type',
params: {
type: 'number'
},
message: 'should be number'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field13',
schemaPath: '#/properties/field13/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field13',
schemaPath: '#/properties/field13/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field14;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "boolean") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field14',
schemaPath: '#/properties/field14/anyOf/0/type',
params: {
type: 'boolean'
},
message: 'should be boolean'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field14',
schemaPath: '#/properties/field14/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field14',
schemaPath: '#/properties/field14/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field15;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "number") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field15',
schemaPath: '#/properties/field15/anyOf/0/type',
params: {
type: 'number'
},
message: 'should be number'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field15',
schemaPath: '#/properties/field15/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field15',
schemaPath: '#/properties/field15/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field16;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "string") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field16',
schemaPath: '#/properties/field16/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field16',
schemaPath: '#/properties/field16/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field16',
schemaPath: '#/properties/field16/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field17;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "number") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field17',
schemaPath: '#/properties/field17/anyOf/0/type',
params: {
type: 'number'
},
message: 'should be number'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field17',
schemaPath: '#/properties/field17/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field17',
schemaPath: '#/properties/field17/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field18;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "number") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field18',
schemaPath: '#/properties/field18/anyOf/0/type',
params: {
type: 'number'
},
message: 'should be number'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field18',
schemaPath: '#/properties/field18/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field18',
schemaPath: '#/properties/field18/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field19;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "string") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field19',
schemaPath: '#/properties/field19/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field19',
schemaPath: '#/properties/field19/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field19',
schemaPath: '#/properties/field19/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field20;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "string") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field20',
schemaPath: '#/properties/field20/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field20',
schemaPath: '#/properties/field20/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field20',
schemaPath: '#/properties/field20/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field21;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "string") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field21',
schemaPath: '#/properties/field21/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field21',
schemaPath: '#/properties/field21/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field21',
schemaPath: '#/properties/field21/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field22;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "string") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field22',
schemaPath: '#/properties/field22/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field22',
schemaPath: '#/properties/field22/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field22',
schemaPath: '#/properties/field22/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field23;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "string") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field23',
schemaPath: '#/properties/field23/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field23',
schemaPath: '#/properties/field23/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field23',
schemaPath: '#/properties/field23/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field24;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "boolean") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field24',
schemaPath: '#/properties/field24/anyOf/0/type',
params: {
type: 'boolean'
},
message: 'should be boolean'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field24',
schemaPath: '#/properties/field24/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field24',
schemaPath: '#/properties/field24/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field25;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "number") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field25',
schemaPath: '#/properties/field25/anyOf/0/type',
params: {
type: 'number'
},
message: 'should be number'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field25',
schemaPath: '#/properties/field25/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field25',
schemaPath: '#/properties/field25/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field26;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "number") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field26',
schemaPath: '#/properties/field26/anyOf/0/type',
params: {
type: 'number'
},
message: 'should be number'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field26',
schemaPath: '#/properties/field26/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field26',
schemaPath: '#/properties/field26/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field27;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "string") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field27',
schemaPath: '#/properties/field27/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field27',
schemaPath: '#/properties/field27/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field27',
schemaPath: '#/properties/field27/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field28;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "number") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field28',
schemaPath: '#/properties/field28/anyOf/0/type',
params: {
type: 'number'
},
message: 'should be number'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field28',
schemaPath: '#/properties/field28/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field28',
schemaPath: '#/properties/field28/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field29;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "number") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field29',
schemaPath: '#/properties/field29/anyOf/0/type',
params: {
type: 'number'
},
message: 'should be number'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field29',
schemaPath: '#/properties/field29/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field29',
schemaPath: '#/properties/field29/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field30;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "number") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field30',
schemaPath: '#/properties/field30/anyOf/0/type',
params: {
type: 'number'
},
message: 'should be number'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field30',
schemaPath: '#/properties/field30/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field30',
schemaPath: '#/properties/field30/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field31;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "number") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field31',
schemaPath: '#/properties/field31/anyOf/0/type',
params: {
type: 'number'
},
message: 'should be number'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field31',
schemaPath: '#/properties/field31/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field31',
schemaPath: '#/properties/field31/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field32;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "number") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field32',
schemaPath: '#/properties/field32/anyOf/0/type',
params: {
type: 'number'
},
message: 'should be number'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field32',
schemaPath: '#/properties/field32/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field32',
schemaPath: '#/properties/field32/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field33;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (errors === errs_2) {
if (typeof data1 === "string") {
if (!formats['date-time'].test(data1)) {
var err = {
keyword: 'format',
dataPath: (dataPath || '') + '.field33',
schemaPath: '#/properties/field33/anyOf/0/format',
params: {
format: 'date-time'
},
message: 'should match format "date-time"'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
} else {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field33',
schemaPath: '#/properties/field33/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (errors === errs_2) {
if (typeof data1 === "string") {
if (!formats.date.test(data1)) {
var err = {
keyword: 'format',
dataPath: (dataPath || '') + '.field33',
schemaPath: '#/properties/field33/anyOf/1/format',
params: {
format: 'date'
},
message: 'should match format "date"'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
} else {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field33',
schemaPath: '#/properties/field33/anyOf/1/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field33',
schemaPath: '#/properties/field33/anyOf/2/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field33',
schemaPath: '#/properties/field33/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field34;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "string") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field34',
schemaPath: '#/properties/field34/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field34',
schemaPath: '#/properties/field34/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field34',
schemaPath: '#/properties/field34/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field35;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (typeof data1 !== "string") {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field35',
schemaPath: '#/properties/field35/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field35',
schemaPath: '#/properties/field35/anyOf/1/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field35',
schemaPath: '#/properties/field35/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field36;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (errors === errs_2) {
if (typeof data1 === "string") {
if (!formats['date-time'].test(data1)) {
var err = {
keyword: 'format',
dataPath: (dataPath || '') + '.field36',
schemaPath: '#/properties/field36/anyOf/0/format',
params: {
format: 'date-time'
},
message: 'should match format "date-time"'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
} else {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field36',
schemaPath: '#/properties/field36/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (errors === errs_2) {
if (typeof data1 === "string") {
if (!formats.date.test(data1)) {
var err = {
keyword: 'format',
dataPath: (dataPath || '') + '.field36',
schemaPath: '#/properties/field36/anyOf/1/format',
params: {
format: 'date'
},
message: 'should match format "date"'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
} else {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field36',
schemaPath: '#/properties/field36/anyOf/1/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field36',
schemaPath: '#/properties/field36/anyOf/2/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field36',
schemaPath: '#/properties/field36/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field37;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (errors === errs_2) {
if (typeof data1 === "string") {
if (!formats['date-time'].test(data1)) {
var err = {
keyword: 'format',
dataPath: (dataPath || '') + '.field37',
schemaPath: '#/properties/field37/anyOf/0/format',
params: {
format: 'date-time'
},
message: 'should match format "date-time"'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
} else {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field37',
schemaPath: '#/properties/field37/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (errors === errs_2) {
if (typeof data1 === "string") {
if (!formats.date.test(data1)) {
var err = {
keyword: 'format',
dataPath: (dataPath || '') + '.field37',
schemaPath: '#/properties/field37/anyOf/1/format',
params: {
format: 'date'
},
message: 'should match format "date"'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
} else {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field37',
schemaPath: '#/properties/field37/anyOf/1/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field37',
schemaPath: '#/properties/field37/anyOf/2/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field37',
schemaPath: '#/properties/field37/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
if (valid1) {
var data1 = data.field38;
if (data1 === undefined) {
valid1 = true;
} else {
var errs_1 = errors;
var errs__1 = errors;
var valid1 = false;
var errs_2 = errors;
if (errors === errs_2) {
if (typeof data1 === "string") {
if (!formats['date-time'].test(data1)) {
var err = {
keyword: 'format',
dataPath: (dataPath || '') + '.field38',
schemaPath: '#/properties/field38/anyOf/0/format',
params: {
format: 'date-time'
},
message: 'should match format "date-time"'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
} else {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field38',
schemaPath: '#/properties/field38/anyOf/0/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (errors === errs_2) {
if (typeof data1 === "string") {
if (!formats.date.test(data1)) {
var err = {
keyword: 'format',
dataPath: (dataPath || '') + '.field38',
schemaPath: '#/properties/field38/anyOf/1/format',
params: {
format: 'date'
},
message: 'should match format "date"'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
} else {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field38',
schemaPath: '#/properties/field38/anyOf/1/type',
params: {
type: 'string'
},
message: 'should be string'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
if (!valid1) {
var errs_2 = errors;
if (data1 !== null) {
var err = {
keyword: 'type',
dataPath: (dataPath || '') + '.field38',
schemaPath: '#/properties/field38/anyOf/2/type',
params: {
type: 'null'
},
message: 'should be null'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
}
var valid2 = errors === errs_2;
valid1 = valid1 || valid2;
}
}
if (!valid1) {
var err = {
keyword: 'anyOf',
dataPath: (dataPath || '') + '.field38',
schemaPath: '#/properties/field38/anyOf',
params: {},
message: 'should match some schema in anyOf'
};
if (vErrors === null) vErrors = [err];
else vErrors.push(err);
errors++;
validate.errors = vErrors;
return false;
} else {
errors = errs__1;
if (vErrors !== null) {
if (errs__1) vErrors.length = errs__1;
else vErrors = null;
}
}
var valid1 = errors === errs_1;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
} else {
validate.errors = [{
keyword: 'type',
dataPath: (dataPath || '') + "",
schemaPath: '#/type',
params: {
type: 'object'
},
message: 'should be object'
}];
return false;
}
validate.errors = vErrors;
return errors === 0;
}
// Sampledata that matches the validator function
const resolveEntitiy = {
"field1": "RESVAL00",
"field2": "RESVAL01",
"field3": "RESVAL02",
"field4": "RESVAL03",
"field5": false,
"field6": "RESVAL04",
"field7": "RESVAL05",
"field8": null,
"field9": null,
"field10": null,
"field11": 0,
"field12": 0,
"field13": 0,
"field14": false,
"field15": 0,
"field16": "RESVAL06",
"field17": 0,
"field18": 0,
"field19": "RESVAL07",
"field20": "RESVAL08",
"field21": "RESVAL09",
"field22": "RESVAL10",
"field23": "RESVAL11",
"field24": false,
"field25": 0,
"field26": 0,
"field27": "RESVAL12",
"field28": 0,
"field29": 0,
"field30": 0,
"field31": 0,
"field32": 0,
"field33": "2019-05-09T04:32:34+00:00",
"field34": null,
"field35": "RESVAL13",
"field36": "2019-05-11T03:14:50+00:00",
"field37": "2019-05-21T10:16:00+00:00"
};
// Sampledata that does not match the validator function
const rejectEntity = {
"field1": "REJVAL00",
"field2": "REJVAL01",
"field3": "REJVAL02",
"field4": "REJVAL03",
"field5": false,
"field6": "REJVAL04",
"field7": "REJVAL05",
"field8": null,
"field9": null,
"field10": null,
"field11": null,
"field12": null,
"field13": null,
"field14": false,
"field15": 0,
"field16": "REJVAL06",
"field17": null,
"field18": null,
"field19": "REJVAL07",
"field20": null,
"field21": null,
"field22": null,
"field23": null,
"field24": false,
"field25": null,
"field26": null,
"field27": null,
"field28": null,
"field29": null,
"field30": null,
"field31": null,
"field32": null,
"field33": "REJVAL08",
"field34": null,
"field35": null,
"field36": "REJVAL09",
"field37": "REJVAL10"
};
// generate sample-data of 1000 elements where 50% will fail and 50% will fulfill validatorFunction
const entities = [];
for(let i = 0; i < 1000; i++) {
entities[i] = i % 2 ? {...resolveEntitiy} : {...rejectEntity};
}
// testing generated sample-data with validateFunction
console.log('Processing entities...');
entities.forEach((entity, index) => {
const start = Date.now();
// this call will freeze on nodeJS versions >= 10.0.0
validateFunction(entity);
console.log(`Processed entity ${index}/${entities.length} in ${Date.now()-start}ms`);
});
console.log('done');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment