export const validation = { isValidEmail(email: string): boolean { const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; return emailRegex.test(email); }, isValidAmount(amount: string | number): boolean { const num = typeof amount === 'string' ? parseFloat(amount) : amount; return !isNaN(num) && num > 0; }, isNonEmpty(value: string): boolean { return value.trim().length > 0; }, minLength(value: string, min: number): boolean { return value.trim().length >= min; }, maxLength(value: string, max: number): boolean { return value.trim().length <= max; }, isPositiveNumber(value: string | number): boolean { const num = typeof value === 'string' ? parseFloat(value) : value; return !isNaN(num) && num > 0; }, isNonNegativeNumber(value: string | number): boolean { const num = typeof value === 'string' ? parseFloat(value) : value; return !isNaN(num) && num >= 0; }, validateForm>( values: T, rules: Partial string | null>> ): Partial> { const errors: Partial> = {}; for (const field in rules) { const validator = rules[field]; if (validator) { const error = validator(values[field]); if (error) { errors[field] = error; } } } return errors; }, };