Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { Tr8AST } from "../../domain/ast.js";
import { SemanticValidationRule, ValidationResult } from "../validator.js";
class NoMaxAndOverdraftRule implements SemanticValidationRule {
validate(ast: Tr8AST): ValidationResult {
const { txs } = ast;
for (const tx of txs) {
for (const source of tx.sources) {
const { constraints, allocationPolicy } = source;
const hasMax = allocationPolicy.policy === "max";
const hasOverdraft = constraints.some(
(c) => c.constraint === "overdraft",
);
Eif (hasMax && hasOverdraft) {
return {
isValid: false,
errors: [
"Source cannot have both max allocation policy and overdraft constraint.",
],
};
}
}
}
return {
isValid: true,
errors: [],
};
}
}
export { NoMaxAndOverdraftRule };
|