UNPKG

@resk/core

Version:

An innovative TypeScript framework that empowers developers to build applications with a fully decorator-based architecture for efficient resource management. By combining the power of decorators with a resource-oriented design, DecorRes enhances code cla

153 lines (152 loc) 4.75 kB
/** * ## Laravel Validation Rules - Translation Keys * * This file contains all translation keys and their default English messages used * throughout the Laravel-compatible validation rules implementation. These translations * provide comprehensive error messages for all validation scenarios. * * ### Usage * ```typescript * import { laravelValidationTranslations } from './translations'; * * // Register translations with i18n system * i18n.addTranslations('en', laravelValidationTranslations); * * // Or merge with existing translations * i18n.mergeTranslations('en', { * validator: laravelValidationTranslations.validator * }); * ``` * * ### Translation Parameters * Most translation messages support dynamic parameters: * - `{field}` - The field name being validated * - `{value}` - The actual value being validated * - `{rule}` - The validation rule name * - `{translatedPropertyName}` - The translated/display name of the field * * @author Resk Framework Team * @since 1.22.0 * @public */ export interface LaravelValidationTranslations { validator: { accepted: string; acceptedIf: string; boolean: string; declined: string; declinedIf: string; alpha: string; alphaDash: string; alphaNum: string; ascii: string; confirmed: string; email: string; endsWith: string; startsWith: string; string: string; url: string; lowercase: string; uppercase: string; between: string; decimal: string; integer: string; max: string; min: string; multipleOf: string; numeric: string; gt: string; gte: string; lt: string; lte: string; array: string; arrayKeys: string; filled: string; in: string; notIn: string; required: string; requiredIf: string; size: string; distinct: string; present: string; prohibited: string; prohibitedIf: string; prohibitedUnless: string; requiredUnless: string; requiredWith: string; requiredWithAll: string; requiredWithout: string; requiredWithoutAll: string; missing: string; missingIf: string; missingUnless: string; missingWith: string; missingWithAll: string; missingWithout: string; missingWithoutAll: string; different: string; same: string; regex: string; notRegex: string; json: string; hexColor: string; macAddress: string; ip: string; ipv4: string; ipv6: string; invalidRuleParams: string; invalidType: string; invalidCompareField: string; invalidRegex: string; }; } /** * Default English translations for Laravel validation rules. * * These messages follow Laravel's standard error message patterns and include * support for dynamic field names, values, and rule-specific parameters. */ export declare const laravelValidationTranslations: LaravelValidationTranslations; /** * French translations for Laravel validation rules. * * Example of how to extend translations for multiple languages. */ export declare const laravelValidationTranslationsFr: LaravelValidationTranslations; /** * Helper function to register Laravel validation translations with the i18n system. * * @param language - The language code (e.g., 'en', 'fr', 'es') * @param translations - The translation object * * @example * ```typescript * // Register English translations * registerLaravelTranslations('en', laravelValidationTranslations); * * // Register French translations * registerLaravelTranslations('fr', laravelValidationTranslationsFr); * * // Register custom translations * registerLaravelTranslations('es', { * validator: { * required: 'El campo {field} es obligatorio.', * email: 'El campo {field} debe ser un email válido.', * // ... other Spanish translations * } * }); * ``` */ export declare function registerLaravelTranslations(language: string, translations: LaravelValidationTranslations): void; /** * Get all available translation keys for Laravel validation rules. * Useful for translation management and ensuring completeness. */ export declare function getLaravelValidationKeys(): string[]; /** * Validate that a translation object has all required keys. * * @param translations - The translation object to validate * @returns Array of missing keys, empty if complete */ export declare function validateTranslationCompleteness(translations: Partial<LaravelValidationTranslations>): string[];