MX Message - ISO20022 Parser Library
A Rust library for parsing, validating, and serializing ISO20022 financial messages with support for CBPR+ (Central Bank Payment Regulation Plus) compliant schemas.
Features
- CBPR+ Compliance: Full support for Central Bank Payment Regulation Plus based ISO20022 XSD schemas
- Multiple Message Types: Support for pacs.008, pacs.009, and camt message families
- Validation: Built-in validation for all message fields according to ISO20022 and CBPR+ specifications
- Serialization: Support for JSON and XML serialization/deserialization using serde
- Type Safety: Strongly typed Rust structures for all message components
- Error Handling: Comprehensive error reporting with specific validation codes
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
= "1.0" # For JSON serialization
= { = "0.31", = ["serialize"] } # For XML serialization
Quick Start
Creating a pacs.008 Message
use Document;
use *;
Validation
use Document;
JSON Serialization
use serde_json;
XML Serialization
use to_string as xml_to_string;
use from_str as xml_from_str;
Examples
Run the included examples to see the library in action:
# Basic pacs.008 message creation and validation
# XML serialization demonstration
CBPR+ Compliance
This library implements CBPR+ (Central Bank Payment Regulation Plus) compliant schemas, which provide enhanced payment processing capabilities including:
- Enhanced Validation: Stricter validation rules for regulatory compliance
- Extended Message Support: Additional message types for comprehensive payment processing
- Improved Error Handling: Detailed error reporting for regulatory requirements
- Central Bank Integration: Support for central bank payment system requirements
Validation
The library provides comprehensive validation including:
- Field Length Validation: Ensures all fields meet minimum and maximum length requirements
- Pattern Validation: Validates formats like IBAN, BIC codes, and numeric patterns
- Required Field Validation: Ensures all mandatory fields are present
- Business Rule Validation: Implements ISO20022 and CBPR+ business rules
- Regulatory Compliance: Validates against CBPR+ specific requirements
Validation Error Codes
1001: Field is shorter than minimum length1002: Field exceeds maximum length1005: Field does not match required pattern9999: Unknown document type
Testing
Run the test suite:
# Run all tests
# Run with output
# Run specific test
Supported Message Types
Currently Supported (CBPR+ Compliant)
Payment Messages (pacs)
- pacs.008.001.08: FI to FI Customer Credit Transfer
- pacs.009.001.08: FI to FI Customer Direct Debit
Cash Management Messages (camt)
- camt.029.001.09: Resolution of Investigation
- camt.056.001.08: FI to FI Payment Cancellation Request
- camt.057.001.06: Notification to Receive
Planned Support
- pacs.002: FI to FI Payment Status Report
- pacs.004: Payment Return
- pain.001: Customer Credit Transfer Initiation
- pain.002: Customer Payment Status Report
- Additional CAMT message types
Architecture
The library is structured around CBPR+ compliant schemas:
src/
├── lib.rs # Module declarations
├── document.rs # Main document types and validation
├── common.rs # Shared types and validation errors
├── pacs_008_001_08.rs # FI to FI Customer Credit Transfer
├── pacs_009_001_08.rs # FI to FI Customer Direct Debit
├── camt_029_001_09.rs # Resolution of Investigation
├── camt_056_001_08.rs # Payment Cancellation Request
└── camt_057_001_06.rs # Notification to Receive
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. When contributing:
- Ensure all new message types follow CBPR+ compliance standards
- Add comprehensive tests for new functionality
- Update documentation for any new features
- Follow existing code style and validation patterns
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.
Acknowledgments
- This library implements the ISO20022 standard as defined by the International Organization for Standardization (ISO)
- CBPR+ compliance ensures compatibility with Central Bank Payment Regulation Plus requirements
- Thanks to the Rust community for excellent serialization and XML processing libraries