[capture] Phones: strict Shortcut post and bank-notification templates (registry empty until real samples)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
//! Fiscus Domi's capture: what the phones send, parsed strictly. Both are hostile input: a post or a
|
||||
//! notification becomes one [`Capture`] or nothing, never a partial payment. Pure: times are parameters.
|
||||
|
||||
pub mod amount;
|
||||
pub mod notification;
|
||||
pub mod shortcut;
|
||||
|
||||
use fiscus_ledger::{Date, Haler, Timestamp};
|
||||
|
||||
/// One card payment a phone saw: an outflow, so `amount` is negative.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Capture {
|
||||
pub amount: Haler,
|
||||
pub date: Date,
|
||||
pub at: Timestamp,
|
||||
pub merchant: String,
|
||||
pub card: Option<String>,
|
||||
}
|
||||
|
||||
/// 1–200 characters, no control characters.
|
||||
pub(crate) fn merchant_ok(s: &str) -> bool {
|
||||
!s.trim().is_empty() && s.chars().count() <= 200 && !s.chars().any(|c| c.is_control())
|
||||
}
|
||||
|
||||
/// 0–60 characters, no control characters.
|
||||
pub(crate) fn card_ok(s: &str) -> bool {
|
||||
s.chars().count() <= 60 && !s.chars().any(|c| c.is_control())
|
||||
}
|
||||
Reference in New Issue
Block a user