@digitalasset/daml-ledger
Version:
DAML Ledger API Node.js bindings
29 lines • 936 B
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.typeOf = exports.init = exports.noFields = exports.isValid = void 0;
function isValid(tree) {
return tree.errors.length === 0 && Object.keys(tree.children).every(child => isValid(tree.children[child]));
}
exports.isValid = isValid;
exports.noFields = () => ({});
function init(key, validation) {
const node = {
children: {},
errors: []
};
if (key && validation) {
validation.children[key] = node;
}
return node;
}
exports.init = init;
function typeOf(value) {
if (value === null)
return 'null';
const t = typeof value;
return t === 'object' && Array.isArray(value) ? 'array' : t;
}
exports.typeOf = typeOf;
//# sourceMappingURL=Validation.js.map