Skip to main content

Module schemes

Module schemes 

Source
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:

  1. XML-based (SchemeValidator::validate) — operates on raw XML strings using lightweight string scanning (xml_scan).
  2. Typed (SchemeValidator::validate_typed) — operates on deserialized message structs via std::any::Any downcasting.

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:

StyleExampleWhen
Absolute/Document/FIToFICstmrCdtTrf/GrpHdr/MsgIdTyped path (field known)
Abbreviated//BICFIXML scan (element found anywhere)
Root element/AppHdrEnvelope-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
FedNow payment scheme validator.
sepa
SEPA (Single Euro Payments Area) scheme validator.
xml_scan
Lightweight XML element and attribute extraction utilities.

Traits§

SchemeValidator
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".