@palmares/schemas
Version:
This defines a default schema definition for validation of data, it abstract popular schema validation libraries like zod, yup, valibot and others"
31 lines • 1.53 kB
TypeScript
import type { SupportedSchemas } from '../../types';
import type { WithFallback } from '../../utils';
import type { SchemaAdapter } from '../index';
import type { AdapterToStringArgs, AdapterTranslateArgs, ErrorCodes } from '../types';
export declare function fieldAdapter<TTranslate extends FieldAdapter['translate'], TToString extends FieldAdapter['toString'], TFormatError extends FieldAdapter['formatError'], TParse extends FieldAdapter['parse']>(args: {
translate: TTranslate;
toString?: TToString;
formatError?: TFormatError;
parse?: TParse;
}): typeof FieldAdapter & {
new (): FieldAdapter & {
translate: TTranslate;
toString: TToString;
formatError: TFormatError;
parse: TParse;
};
};
export declare class FieldAdapter {
translate(_fieldAdapter: FieldAdapter, _args: AdapterTranslateArgs<SupportedSchemas>, _base?: any): any | WithFallback<SupportedSchemas>;
parse(_adapter: SchemaAdapter, _fieldAdapter: FieldAdapter, _schema: any, _value: any, _args: Omit<AdapterTranslateArgs<SupportedSchemas>, 'withFallback'>): Promise<{
errors: any;
parsed: any;
}>;
toString(_adapter: SchemaAdapter, _fieldAdapter: FieldAdapter, _args: AdapterToStringArgs, _base?: any): Promise<string>;
formatError(_adapter: SchemaAdapter, _fieldAdapter: FieldAdapter, _schema: any, _error: any, _metadata?: any): Promise<{
message: string;
path: (string | number)[];
code: ErrorCodes;
}>;
}
//# sourceMappingURL=index.d.ts.map