Expand description
Payment scheme-specific validation.
Each payment scheme (FedNow, SEPA, CBPR+) has additional rules beyond the
base ISO 20022 schema. This module provides validators that enforce these
scheme-specific constraints.
§Design
Scheme validators support two validation paths:
- XML-based (
SchemeValidator::validate) — operates on raw XML strings using lightweight string scanning (xml_scan). - Typed (
SchemeValidator::validate_typed) — operates on deserialized message structs viastd::any::Anydowncasting.
The typed path is preferred when the caller has already deserialized the message. It avoids fragile XML string scanning and catches field-level issues at compile time (within the validator implementation).
§Error Paths
Error paths in ValidationError follow
XPath-like conventions:
| Style | Example | When |
|---|---|---|
| Absolute | /Document/FIToFICstmrCdtTrf/GrpHdr/MsgId | Typed path (field known) |
| Abbreviated | //BICFI | XML scan (element found anywhere) |
| Root element | /AppHdr | Envelope-level checks |
New validators should prefer absolute paths when the field location is
known (always the case for typed validators). Abbreviated //Element
paths are acceptable for XML-scan checks that match elements regardless
of position.
§Usage
use mx20022_validate::schemes::fednow::FedNowValidator;
use mx20022_validate::schemes::SchemeValidator;
let validator = FedNowValidator::new();
let xml = r#"<?xml version="1.0"?><Document xmlns="urn:iso:std:iso:20022:tech:xsd:pacs.008.001.13"></Document>"#;
let result = validator.validate(xml, "pacs.008.001.13");
// Result may contain errors for missing mandatory fields.
println!("{} error(s)", result.error_count());Modules§
- cbpr
- CBPR+ (Cross-Border Payments and Reporting Plus) scheme validator.
- fednow
FedNowpayment scheme validator.- sepa
- SEPA (Single Euro Payments Area) scheme validator.
- xml_
scan - Lightweight XML element and attribute extraction utilities.
Traits§
- Scheme
Validator - A scheme-specific validator for ISO 20022 payment messages.
Functions§
- short_
message_ type - Extract the short message type (e.g.
"pacs.008") from a full type string like"pacs.008.001.13".