fhirbuilder
Version:
Another FHIR Tool to build FHIR Resources
37 lines (36 loc) • 1.65 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BundleEntryValidator = BundleEntryValidator;
const definitions_1 = require("../base/definitions");
const base_1 = require("../base");
const utils_1 = require("../../../commons/utils");
const models_1 = require("../../../../r4/models");
/**
* @description The model fields for the BundleEntry model
*/
const modelFields = (0, definitions_1.createBackboneDefinition)([
{ name: 'link', type: 'BundleLink', isArray: true, isRequired: false },
{ name: 'fullUrl', type: 'uri', isArray: false, isRequired: false },
{ name: '_fullUrl', type: 'Element', isArray: false, isRequired: false },
{ name: 'resource', type: 'Resource', isArray: false, isRequired: false },
{ name: 'search', type: 'BundleSearch', isArray: false, isRequired: false },
{ name: 'request', type: 'BundleRequest', isArray: false, isRequired: false },
{ name: 'response', type: 'BundleResponse', isArray: false, isRequired: false },
]);
/**
* @description Validates the BundleEntry model
* @param dataToValidate - the BundleEntry model to validate
* @param path - the path to the model
* @param errors - the errors array
*/
function BundleEntryValidator(dataToValidate, path = 'BundleEntry', errors = []) {
// Ensure that the model fields match the attributes of the model
(0, utils_1.AssertModelFieldsMatchAttributes)(modelFields, new models_1.BundleEntry());
// Validate the model and add any errors to the errors array
(0, base_1.ModelValidator)({
dataToValidate,
modelDefinition: modelFields,
path,
errors,
});
}