UNPKG

@poseidat/schemas

Version:

The core schemas for the PoseiDAT data interchange formats

37 lines 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BaseEntry = void 0; var schema_validator_1 = require("./schema-validator"); var schemas_1 = require("./schemas"); /** * Convenience class for constructing and validating an Entry * Can be extended by other entry classes to reuse validation logic * * @export * @class BaseEntry */ var BaseEntry = /** @class */ (function () { /** * Creates an instance of Entry * * @param {ICoreBaseEntry} [data={}] The data to initialize the Entry with */ function BaseEntry(data, schema, entryType) { if (schema === void 0) { schema = schemas_1.schemas.core.baseEntry; } if (entryType === void 0) { entryType = 'base-entry'; } this.data = data; this.schema = schema; this.data.entry_type = entryType; } /** * Validates the current Entry data against the core schema * * @returns {ajv.ErrorObject[]} */ BaseEntry.prototype.validate = function () { return (0, schema_validator_1.validateSchema)({ object: this.data, schema: this.schema }); }; return BaseEntry; }()); exports.BaseEntry = BaseEntry; //# sourceMappingURL=base-entry.js.map