Extract validation orchestration logic into dedicated ModalValidator class as part of Phase 4 modal refactoring to improve maintainability. Changes: - Create src/ui/modal/ModalValidator.ts with validateAllSections() method - Remove validateAllSections() method from ExportConfigModal.ts - Update ExportConfigModal to delegate validation to ModalValidator - Fix TypeScript handling of optional warnings property - Maintain exact same validation behavior and error handling Build: ✅ npm run build passes Size: ExportConfigModal.ts reduced by ~20 lines 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
41 lines
965 B
TypeScript
41 lines
965 B
TypeScript
/**
|
|
* Modal validation orchestration
|
|
*
|
|
* This class handles validation logic for the export configuration modal,
|
|
* coordinating validation across all modal sections.
|
|
*/
|
|
|
|
import { ModalSection, ValidationResult } from './modalTypes';
|
|
|
|
/**
|
|
* Handles validation orchestration for modal sections
|
|
*/
|
|
export class ModalValidator {
|
|
|
|
/**
|
|
* Validates all sections and aggregates the results
|
|
*
|
|
* @param sections - Array of modal sections to validate
|
|
* @returns ValidationResult with aggregated errors and warnings
|
|
*/
|
|
public validateAllSections(sections: ModalSection[]): ValidationResult {
|
|
const errors: string[] = [];
|
|
const warnings: string[] = [];
|
|
|
|
sections.forEach(section => {
|
|
if (section.validate) {
|
|
const result = section.validate();
|
|
errors.push(...result.errors);
|
|
if (result.warnings) {
|
|
warnings.push(...result.warnings);
|
|
}
|
|
}
|
|
});
|
|
|
|
return {
|
|
isValid: errors.length === 0,
|
|
errors,
|
|
warnings
|
|
};
|
|
}
|
|
} |