How to use ajv.errorsText:
29 30 31 32 33 34 35 36 37 38
let valid = validate(payload); if (valid && !validate.errors) { resolve(_.cloneDeep(payload)); } else { let message = ajv.errorsText(validate.errors); reject(new error.InternalValidationError(message)); } } catch (err) {
How to use ajv.ValidationError:
86 87 88 89 90 91 92 93 94 95
null, '' ); } catch (e) { myerror.message = e.message; throw new AJV.ValidationError([myerror]); } // does pointed-to data match required schema? if (!v(tgt)) {
62
143
53
See more examples
How to use ajv.default:
GitHub: DeMaCS-UNICAL/LoIDE
183 184 185 186 187 188 189 190 191 192
// Loading files var json = require(jsonPath); var schema = require(schemaPath); // Config var ajv = new Ajv.default({ allErrors: true }); // Adding format support
5
21
10
See more examples
How to use ajv.compile:
363 364 365 366 367 368 369 370 371 372 373
const schema = datasetUtils.jsonSchema(dataset.schema.filter(p => !p['x-calculated'] && !p['x-extension'])) schema.additionalProperties = false schema.properties._id = { type: 'string' } // super-admins can set _updatedAt and so rewrite history if (adminMode) schema.properties._updatedAt = { type: 'string', format: 'date-time' } return ajv.compile(schema) } async function manageAttachment (req, keepExisting) { if (req.is('multipart/form-data')) {