datapilot-cli
Version:
Enterprise-grade streaming multi-format data analysis with comprehensive statistical insights and intelligent relationship detection - supports CSV, JSON, Excel, TSV, Parquet - memory-efficient, cross-platform
87 lines • 2.69 kB
TypeScript
/**
* Comprehensive Input Validation and Sanitization System
* Prevents errors through strict input validation and safe defaults
*/
export interface ValidationRule<T = any> {
validate: (value: T) => boolean;
message: string;
severity: 'error' | 'warning';
sanitize?: (value: T) => T;
}
export interface ValidationSchema {
[key: string]: {
type: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'function' | 'buffer';
required?: boolean;
rules?: ValidationRule[];
default?: any;
min?: number;
max?: number;
pattern?: RegExp;
enum?: any[];
nested?: ValidationSchema;
};
}
export interface ValidationResult {
isValid: boolean;
errors: ValidationError[];
warnings: ValidationError[];
sanitizedValue: any;
}
export interface ValidationError {
field: string;
message: string;
severity: 'error' | 'warning';
value: any;
expectedType?: string;
}
export declare class InputValidator {
private static readonly FILE_SIZE_LIMITS;
private static readonly SECURITY_PATTERNS;
/**
* Validate and sanitize file path
*/
static validateFilePath(filePath: string): Promise<ValidationResult>;
/**
* Validate worker pool configuration
*/
static validateWorkerPoolConfig(config: any): ValidationResult;
/**
* Validate streaming configuration
*/
static validateStreamingConfig(config: any): ValidationResult;
/**
* Validate buffer data
*/
static validateBuffer(buffer: any, maxSize?: number): ValidationResult;
/**
* Validate and sanitize CSV parsing options
*/
static validateCSVOptions(options: any): ValidationResult;
/**
* Validate numeric array data
*/
static validateNumericArray(data: any, fieldName?: string): ValidationResult;
/**
* Generic object validation against schema
*/
static validateObject(obj: any, schema: ValidationSchema, objectName?: string): ValidationResult;
/**
* Type validation helper
*/
private static validateType;
/**
* Security sanitization for string inputs
* Uses comprehensive HTML filtering to prevent XSS attacks
*/
static sanitizeString(input: string): string;
/**
* Secure HTML sanitization for content that may contain HTML
* Implements a whitelist approach for maximum security
*/
static sanitizeHTML(input: string, allowedTags?: string[]): string;
/**
* Validate and throw on validation errors
*/
static validateAndThrow(result: ValidationResult, operation: string): any;
}
//# sourceMappingURL=input-validator.d.ts.map