UNPKG

jinaga

Version:

Data management for web and mobile applications.

24 lines 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.validatePurgeSpecification = void 0; function validatePurgeSpecification(specification) { // Validate that the specification has only one given. if (specification.given.length !== 1) { return ["A purge specification must have exactly one given."]; } var purgeRoot = specification.given[0]; // Search for negative existential conditions. // Those indicate that the specification will reverse a purge. var failures = specification.matches.map(match => match.conditions .filter(isNegativeExistentialCondition) .map(condition => `A specified purge condition would reverse the purge of ${purgeRoot.type} with ${describeTuple(condition.matches)}.`)).flat(); return failures; } exports.validatePurgeSpecification = validatePurgeSpecification; function isNegativeExistentialCondition(condition) { return condition.type === "existential" && !condition.exists; } function describeTuple(matches) { return matches.map(match => match.unknown.type).join(", "); } //# sourceMappingURL=validate.js.map