Message Validation
ValidationEngine
A single entry point for validating any SWIFT message — MT or MX. Initialize the engine, pass a message, and receive a detailed list of validation problems with error codes, field references, and human-readable descriptions.
// Create the validation engine
ValidationEngine engine =
new ValidationEngine();
// Validate an MT message from FIN string
List<ValidationProblem> r =
engine.validateMtMessage(fin);
// Print human-readable results
System.out.println(
ValidationProblem.printout(r)); MX / ISO 20022 Validation
Cross-element and externalized ISO code validation for all MX message types and all versions. Includes CBPR+ schema and Usage Guideline validation out of the box, with an extendable API to inject custom schemas and custom UG validation modules.
// Build an MX pain.001 and validate
MxPain00100108 pain001 =
new MxPain00100108();
CustomerCreditTransferInitiationV08 ccti =
new CustomerCreditTransferInitiationV08()
.setGrpHdr(new GroupHeader48()
.setCtrlSum(new BigDecimal(100))
.setMsgId("MYREF"))
.addPmtInf(new PaymentInstruction22()
.setDbtr(new PartyIdentification43()
.setNm("foo")));
pain001.setCstmrCdtTrfInitn(ccti);
List<ValidationProblem> r =
engine.validateMessage(pain001); MT Validation Rules
Complete implementation of SWIFT network validation rules for all MT message categories. Every semantic rule per message type is covered — from field format and qualifier constraints to conditional presence and cross-field dependencies.
// Validate a typed MT103 object
MT103 m = new MT103();
m.setSender("FOOSEDR0AXXX");
m.setReceiver("FOORECV0XXXX");
m.addField(new Field20("REFERENCE"));
m.addField(new Field32A()
.setDate(Calendar.getInstance())
.setCurrency("USD"));
m.addField(new Field59A()
.setIdentifierCode("ABCDZZXXXX"));
List<ValidationProblem> r =
engine.validateMessage(m);
System.out.println(
ValidationProblem.printout(r)); Custom Validation Rules
Inject your own business rules into the validation pipeline. Custom rules run after all standard SWIFT rules and have full access to the message model, allowing you to enforce institution-specific policies alongside network compliance.
// Add custom rules to the engine
engine.getConfig().addCustomRule(
"103", new MyRule());
engine.getConfig().addCustomRule(
"103",
new CustomAmountValidationRule(
new BigDecimal("1000")));
// Custom rule implementation
public class MyRule
extends ValidationRule {
protected List<ValidationProblem>
eval(SwiftMessage msg, String mt) {
Tag ref = msg.getBlock4()
.getTagByName("20");
if (!ref.getValue()
.startsWith("MYREF")) {
result.add(new ValidationProblem(
"BAD_REFERENCE",
"must start with MYREF"));
}
return result;
}
} ACK / NAK Creation
Automatically generate SWIFT-compliant ACK and NAK response messages from validation results. Useful for middleware implementations that need to respond to message senders with standard acknowledgement or rejection messages.
// Validate and generate ACK or NAK
List<ValidationProblem> r =
engine.validateMessage(m);
if (r.isEmpty()) {
String ack =
SwiftMessageFactory.ACK(
m.getSwiftMessage(),
SwiftMessageFactory.Type.ACK,
null,
PositionOptions.ack_then_message);
} else {
String nak =
SwiftMessageFactory.ACK(
m.getSwiftMessage(),
SwiftMessageFactory.Type.NACK,
r.get(0).getErrorKey(),
PositionOptions.ack_then_message);
} Structure & Format
MT block structure, field ordering, tag presence, character sets, and line counts. MX syntax validation against XSD schemas. Full structural compliance for both standards.
Semantic Rules
MT conditional presence, qualifier constraints, and cross-field dependencies. MX cross-element checks and externalized ISO code validation. Full semantic coverage for both standards.
Date, Amount & IBAN
Date format validation, currency code verification against ISO 4217, amount consistency across related fields, decimal precision checks, and IBAN local format validation.
BIC Validation
BIC format validation and optional live lookup against the BIC directory for institution existence verification.
Sequence Validation
Mandatory and optional sequence ordering for complex MT types (535, 536, 548, 564, 566, etc.) with proper nesting verification.
Custom Rules & Schemas
Your own institution-specific validation logic, custom schemas, and custom Usage Guideline modules — injected into the standard pipeline alongside SWIFT network rules.