/** * Validation Module * * Provides standalone validation system for fields, forms, and data. * * Usage: * - Import and use directly: import { Validator } from './modules/validation/index.js' * - Or use with form-handling module * - Or use with LiveComponents * * Features: * - Schema-based validation * - Field-level validation * - Async validation * - Custom validation rules * - Integration with form-handling * - Integration with LiveComponents */ import { Logger } from '../../core/logger.js'; import { Validator } from './Validator.js'; import { ValidationRule } from './ValidationRule.js'; const ValidationModule = { name: 'validation', init(config = {}, state = null) { Logger.info('[ValidationModule] Module initialized'); // Expose globally for easy access if (typeof window !== 'undefined') { window.Validator = Validator; window.ValidationRule = ValidationRule; } return this; }, /** * Create a validator from a schema */ create(schema = {}) { return Validator.create(schema); }, /** * Create a validator from a form element */ fromForm(form) { return Validator.fromForm(form); }, destroy() { if (typeof window !== 'undefined') { delete window.Validator; delete window.ValidationRule; } Logger.info('[ValidationModule] Module destroyed'); } }; // Export for direct usage export { Validator, ValidationRule }; // Export as default for module system export default ValidationModule; // Export init function for module system export const init = ValidationModule.init.bind(ValidationModule);