/** * FieldValidator - Comprehensive field validation utilities * * Provides reusable validation rules for element metadata fields across all element types. * Each validator returns null on success or a ValidationError object on failure. * * Validation Rules: * - required: Field must be present and non-empty * - type: Field must match expected JavaScript type * - enum: Field value must be in allowed list * - array: Field must be array with optional minLength * - semver: Field must be valid semantic version * - length: String length within min/max bounds * - pattern: Field must match regex pattern * * @module utils/validation */ /** * Validation error structure */ export interface ValidationError { field: string; message: string; } /** * FieldValidator class providing static validation methods */ export declare class FieldValidator { /** * Validate that a field is present and non-empty * * @param value - Value to validate * @param field - Field name for error reporting * @returns ValidationError if invalid, null if valid * * @example * FieldValidator.required(data.name, 'name') * // Returns: null if valid, { field: 'name', message: '...' } if invalid */ static required(value: any, field: string): ValidationError | null; /** * Validate that a field matches the expected JavaScript type * * @param value - Value to validate * @param expectedType - Expected type ('string', 'number', 'boolean', 'object', 'array') * @param field - Field name for error reporting * @returns ValidationError if invalid, null if valid * * @example * FieldValidator.type(data.age, 'number', 'age') * // Returns: null if valid, { field: 'age', message: '...' } if invalid */ static type(value: any, expectedType: string, field: string): ValidationError | null; /** * Validate that a field value is in the allowed list * * @param value - Value to validate * @param allowed - Array of allowed values * @param field - Field name for error reporting * @returns ValidationError if invalid, null if valid * * @example * FieldValidator.enum(data.category, ['creative', 'professional'], 'category') * // Returns: null if valid, { field: 'category', message: '...' } if invalid */ static enum(value: any, allowed: string[], field: string): ValidationError | null; /** * Validate that a field is an array with optional minimum length * * @param value - Value to validate * @param field - Field name for error reporting * @param minLength - Optional minimum array length * @returns ValidationError if invalid, null if valid * * @example * FieldValidator.array(data.elements, 'elements', 1) * // Returns: null if valid, { field: 'elements', message: '...' } if invalid */ static array(value: any, field: string, minLength?: number): ValidationError | null; /** * Validate that a field is a valid semantic version * * Uses the semver package to validate version strings. * * @param value - Value to validate * @param field - Field name for error reporting * @returns ValidationError if invalid, null if valid * * @example * FieldValidator.semver(data.version, 'version') * // Returns: null if valid, { field: 'version', message: '...' } if invalid */ static semverVersion(value: any, field: string): ValidationError | null; /** * Validate that a string length is within specified bounds * * @param value - Value to validate * @param field - Field name for error reporting * @param min - Minimum length (inclusive) * @param max - Maximum length (inclusive) * @returns ValidationError if invalid, null if valid * * @example * FieldValidator.length(data.name, 'name', 1, 100) * // Returns: null if valid, { field: 'name', message: '...' } if invalid */ static length(value: any, field: string, min: number, max: number): ValidationError | null; /** * Validate that a field matches a regular expression pattern * * @param value - Value to validate * @param pattern - Regular expression pattern * @param field - Field name for error reporting * @param patternDescription - Human-readable description of the pattern * @returns ValidationError if invalid, null if valid * * @example * FieldValidator.pattern(data.email, /^[^@]+@[^@]+$/, 'email', 'valid email address') * // Returns: null if valid, { field: 'email', message: '...' } if invalid */ static pattern(value: any, pattern: RegExp, field: string, patternDescription?: string): ValidationError | null; /** * Validate a number is within a specified range * * @param value - Value to validate * @param field - Field name for error reporting * @param min - Minimum value (inclusive) * @param max - Maximum value (inclusive) * @returns ValidationError if invalid, null if valid * * @example * FieldValidator.range(data.proficiency, 'proficiency', 0, 100) * // Returns: null if valid, { field: 'proficiency', message: '...' } if invalid */ static range(value: any, field: string, min: number, max: number): ValidationError | null; } //# sourceMappingURL=FieldValidator.d.ts.map