feat(core): the engine refuses free text that looks like a tax id
Entry and reversal descriptions, write-off and void reasons, document memos, references, duplicate reasons and line descriptions, asset descriptions, serials and tags, period names, account codes, schedule and recurring descriptions and payroll employee names now meet the one free-text detector in the Ledger command itself (FreeTextHoldsTin), so a caller other than the MCP layer cannot journal a tax id (BS-partner-2). Replay never refuses (BS-entry-4). Draft notes, discard reasons, no-party reasons and send references and notes move from the strict nine-digit reading to the shapes (parties::check_note), as the owner chose on 2026-11-21; party fields, names and recipients keep the strict reading. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
ff58b055ce
commit
548901ce7d
9 files changed
+136
-18
No files matched your search
@@ -717,6 +717,22 @@ pub fn check_text(field: &str, text: &str) -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Check a free text field: no tax id's shape (a nine-digit number standing
|
||||
/// alone, an SSN's 3-2-4, an EIN's 2-7: [`crate::settings::check_free_text`]),
|
||||
/// at most 500 characters, no control characters except newline. For a
|
||||
/// memo, a note, a reason or a reference; a party's own fields keep the
|
||||
/// strict [`check_text`] (BS-partner-2; the owner's choice, 2026-11-21).
|
||||
pub fn check_note(field: &str, text: &str) -> Result<(), String> {
|
||||
crate::settings::check_free_text(field, text)?;
|
||||
if text.chars().count() > 500 {
|
||||
return Err(format!("{field} is at most 500 characters"));
|
||||
}
|
||||
if text.chars().any(|c| c.is_control() && c != '\n') {
|
||||
return Err(format!("{field} can't contain control characters"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Check an email address: one line of party text ([`check_text`], which
|
||||
/// refuses a full TIN) in a plain address shape, one `@` and no spaces. Not
|
||||
/// an RFC grammar test: the books only print it, they never send (A-4).
|
||||
|
||||
Reference in new issue
Block a user