@digitalasset/daml-ledger
Version:
DAML Ledger API Node.js bindings
30 lines • 1.05 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.record = void 0;
const Validation_1 = require("./Validation");
function record(values) {
return {
type: `Record<string, ${values.type}>`,
validate(value, key, validation) {
const node = Validation_1.init(key, validation);
const actualType = Validation_1.typeOf(value);
if (actualType !== 'object') {
node.errors.push({
errorType: 'type-error',
expectedType: this.type,
actualType: actualType
});
}
else {
for (const key in value) {
values.validate(value[key], key, node);
}
}
return validation || node;
}
};
}
exports.record = record;
//# sourceMappingURL=Record.js.map