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 34 35 36 37 38 39 40 41 42 43 44 45 | 1x 3x 3x 3x 1x 2x 2x 2x 2x 1x 2x | import { autoInjectable } from "tsyringe";
import { Tr8AST } from "../../domain/ast.js";
import { SemanticValidationRule, ValidationResult } from "../validator.js";
@autoInjectable()
class RelativeRefValueBookSameAsSourceBooksRule
implements SemanticValidationRule
{
validate(ast: Tr8AST): ValidationResult {
const { txs } = ast;
for (const tx of txs) {
if (tx.refValue.type === "absolute") {
continue;
}
const {
book: { book },
} = tx.refValue;
for (const source of tx.sources) {
Iif (source.book.type === "world" || source.extern) {
continue;
}
if (source.book.book !== book) {
return {
isValid: false,
errors: [
"Relative ref value book must be the same as the source books.",
],
};
}
}
}
return {
isValid: true,
errors: [],
};
}
}
export { RelativeRefValueBookSameAsSourceBooksRule };
|