UNPKG

@oxog/kindof

Version:

Zero-dependency advanced type detection library with TypeScript support, plugin system, and 100% test coverage

39 lines (30 loc) 971 B
type SchemaType = string | SchemaObject | SchemaArray; interface SchemaObject { [key: string]: SchemaType; } interface SchemaArray extends Array<SchemaType> {} interface ValidationResult { valid: boolean; errors: ValidationError[]; warnings?: ValidationWarning[]; } interface ValidationError { path: string; expected: string; actual: string; message: string; } interface ValidationWarning { path: string; message: string; } interface ValidationOptions { strict?: boolean; coerce?: boolean; partial?: boolean; path?: string; } declare function validateSchema(value: unknown, schema: SchemaType, options?: ValidationOptions): ValidationResult; declare function createValidator(schema: SchemaType, options?: ValidationOptions): (value: unknown) => ValidationResult; export { createValidator, validateSchema }; export type { SchemaArray, SchemaObject, SchemaType, ValidationError, ValidationOptions, ValidationResult, ValidationWarning };