UNPKG

@sjsf/ajv8-validator

Version:

The ajv-8 based validator for svelte-jsonschema-form

12 lines (11 loc) 1.06 kB
import { type Config, type FailureValidationResult, type FormValue, type UiSchemaRoot } from "@sjsf/form"; import { type AsyncValidateFunction, type ErrorObject, type ValidateFunction } from "ajv"; export interface ErrorsTransformerOptions { uiSchema?: UiSchemaRoot; } export declare function createFormErrorsTransformer({ uiSchema, }: ErrorsTransformerOptions): (errors: ErrorObject[], data: FormValue) => FailureValidationResult; export declare function createFieldErrorsTransformer(config: Config): (errors: ErrorObject[]) => string[]; export type TransformInput<T> = (data: FormValue) => T; export type TransformErrors<R> = (errors: ErrorObject[], data: FormValue) => R; export declare function validateAndTransformErrors<T, R>(validate: ValidateFunction, data: FormValue, transformData: TransformInput<T>, transformErrors: TransformErrors<R>): T | R; export declare function validateAndTransformErrorsAsync<T, R>(validate: AsyncValidateFunction, data: FormValue, transformInput: TransformInput<T>, transformErrors: TransformErrors<R>): Promise<T | R>;