import { HOOKS } from '../../utils/hooks'; import { CoreType } from '../types'; import { CAST_STRATEGY } from '../../utils/cast-strategy'; export declare type SchemaDef = Record; export declare type FieldMap = { [key: string]: IOttomanType; }; export declare type PluginConstructor = (Schema: any) => void; export declare type FactoryFunction = (name: any, options: any) => IOttomanType; /** * Should throw all errors detected */ export declare type OttomanSchemaTypes = 'String' | 'Boolean' | 'Number' | 'Date' | 'Array' | 'Reference' | 'Embed' | 'Mixed'; export declare type ValidatorFunction = (value: unknown) => void; export declare type AutoFunction = () => unknown; export declare type SupportFactoryTypes = { [key in OttomanSchemaTypes]: FactoryFunction; }; export declare type SupportTypes = { [key in OttomanSchemaTypes]: CoreType; }; export declare type CustomValidations = { [key: string]: ValidatorFunction; }; export declare type RequiredFunction = () => boolean | RequiredOption; export declare type HookHandler = (IDocument: any) => void; export declare type Hook = { [key in HOOKS]?: HookHandler[] | HookHandler; }; export interface ValidatorOption { regexp: RegExp; message: string; } export interface RequiredOption { val: boolean; message: string; } export interface CoreTypeOptions { required?: boolean | RequiredOption | RequiredFunction; immutable?: boolean; default?: unknown; validator?: ValidatorOption | ValidatorFunction | string; } export declare abstract class IOttomanType { name: string; typeName: string; protected constructor(name: string, typeName: string); abstract cast(value: unknown, strategy?: CAST_STRATEGY): unknown; abstract validate(value: unknown, strict?: boolean): unknown; } export interface SchemaOptions { strict?: boolean; preHooks?: Hook; postHooks?: Hook; }