/**
 * ISO 20022 XSD validation interface.
 * Full XSD catalog validation is deferred; this hook enables server wiring and tests.
 */

export type SchemaValidationResult = {
  valid: boolean;
  errors: string[];
};

export type Iso20022SchemaValidator = {
  validate(xml: string, messageFamily: string): Promise<SchemaValidationResult>;
};

/** Structural pre-check until official XSD bundles are mounted in services. */
export class PassthroughSchemaValidator implements Iso20022SchemaValidator {
  async validate(xml: string, messageFamily: string): Promise<SchemaValidationResult> {
    const errors: string[] = [];
    if (!xml?.trim()) errors.push('empty_xml');
    if (!messageFamily?.trim()) errors.push('missing_message_family');
    if (xml && !xml.includes('<')) errors.push('not_xml');
    return { valid: errors.length === 0, errors };
  }
}
