@digitalasset/daml-ledger
Version:
DAML Ledger API Node.js bindings
30 lines • 1.04 kB
JavaScript
;
// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
Object.defineProperty(exports, "__esModule", { value: true });
exports.array = void 0;
const Validation_1 = require("./Validation");
function array(items) {
return {
type: `Array<${items.type}>`,
validate(value, key, validation) {
const node = Validation_1.init(key, validation);
if (Array.isArray(value)) {
value.forEach((item, index) => {
items.validate(item, index.toString(), node);
});
}
else {
const error = {
errorType: 'type-error',
expectedType: this.type,
actualType: Validation_1.typeOf(value)
};
node.errors.push(error);
}
return validation || node;
}
};
}
exports.array = array;
//# sourceMappingURL=Array.js.map