import { type ActionFailure, type RequestEvent, type Transport } from '@sveltejs/kit'; import { type ValidationAdapter } from './adapters/adapters.js'; import type { ErrorStatus, IsAny } from './utils.js'; import { type FormPathLeavesWithErrors } from './stringPath.js'; import type { JSONSchema } from './jsonSchema/index.js'; import type { InputConstraints } from './jsonSchema/constraints.js'; import type { SuperStructArray } from './superStruct.js'; import type { SchemaShape } from './jsonSchema/schemaShape.js'; export type SuperFormValidated, Message = App.Superforms.Message extends never ? any : App.Superforms.Message, In extends Record = T> = SuperValidated & { constraints: InputConstraints; }; export type SuperValidated, Message = App.Superforms.Message extends never ? any : App.Superforms.Message, In extends Record = Out> = { id: string; valid: boolean; /** * @deprecated posted is inconsistent between server and client validation, and SPA mode. Will be removed in v3. Use a status message or return your own data in the form action to handle form post status. */ posted: boolean; errors: ValidationErrors; data: Out; constraints?: InputConstraints; message?: Message; shape?: SchemaShape; }; export type ValidationErrors> = { _errors?: string[]; } & SuperStructArray; type SuperValidateData> = RequestEvent | Request | FormData | URLSearchParams | URL | Partial | null | undefined; export type SuperValidateOptions> = Partial<{ errors: boolean; id: string; preprocessed: (keyof Out)[]; defaults: Out; jsonSchema: JSONSchema; strict: boolean; allowFiles: boolean; transport: IsAny extends true ? never : Transport; }>; export type TaintedFields> = SuperStructArray; export declare function superValidate, Message = App.Superforms.Message extends never ? any : App.Superforms.Message, In extends Record = Out>(adapter: ValidationAdapter, options?: SuperValidateOptions): Promise>; export declare function superValidate, M = App.Superforms.Message extends never ? any : App.Superforms.Message, In extends Record = Out>(data: SuperValidateData, adapter: ValidationAdapter, options?: SuperValidateOptions): Promise>; /** * Sends a message with a form, with an optional HTTP status code that will set * form.valid to false if status >= 400. A status lower than 400 cannot be sent. */ export declare function message = Record, In extends Record = Record>(form: SuperValidated, message: M, options?: { status?: ErrorStatus; removeFiles?: boolean; }): { form: SuperValidated; } | ActionFailure<{ form: SuperValidated; }>; export declare const setMessage: typeof message; type SetErrorOptions = { overwrite?: boolean; status?: ErrorStatus; removeFiles?: boolean; }; /** * Sets a form-level error. * form.valid is automatically set to false. * * @param {SuperValidated} form A validation object, usually returned from superValidate. * @param {string | string[]} error Error message(s). * @param {SetErrorOptions} options Option to overwrite previous errors and set a different status than 400. The status must be in the range 400-599. * @returns fail(status, { form }) */ export declare function setError, M, In extends Record>(form: SuperValidated, error: string | string[], options?: SetErrorOptions): ActionFailure<{ form: SuperValidated; }>; /** * Sets an error for a form field or array field. * form.valid is automatically set to false. * * @param {SuperValidated} form A validation object, usually returned from superValidate. * @param {'' | FormPathLeavesWithErrors} path Path to the form field. Use an empty string to set a form-level error. Array-level errors can be set by appending "._errors" to the field. * @param {string | string[]} error Error message(s). * @param {SetErrorOptions} options Option to overwrite previous errors and set a different status than 400. The status must be in the range 400-599. * @returns fail(status, { form }) */ export declare function setError, Path extends FormPathLeavesWithErrors, M, In extends Record>(form: SuperValidated, path: '' | Path, error: string | string[], options?: SetErrorOptions): ActionFailure<{ form: SuperValidated; }>; export declare function withFiles(obj: T): T; export declare const removeFiles: typeof withFiles; export declare function fail | undefined>(status: number, data?: T): ActionFailure; export {};