import { type ComponentDef } from '@defra/forms-model'; import { type CustomValidator, type ErrorReportCollection, type ObjectSchema } from 'joi'; import { type Component, type Field, type Guidance } from '~/src/server/plugins/engine/components/helpers/components.js'; import { type ComponentViewModel } from '~/src/server/plugins/engine/components/types.js'; import { type FormModel } from '~/src/server/plugins/engine/models/index.js'; import { type PageControllerClass } from '~/src/server/plugins/engine/pageControllers/helpers/pages.js'; import { type FormPayload, type FormSubmissionError, type FormSubmissionState, type FormValidationResult } from '~/src/server/plugins/engine/types.js'; import { type FormQuery } from '~/src/server/routes/types.js'; export declare class ComponentCollection { page?: PageControllerClass; parent?: Component; components: Component[]; fields: Field[]; guidance: Guidance[]; formSchema: ObjectSchema; stateSchema: ObjectSchema; constructor(defs: ComponentDef[], props: { page?: PageControllerClass; parent?: Component; model: FormModel; }, schema?: { /** * Defines an all-or-nothing relationship between keys where if one * of the peers is present, all of them are required as well */ peers?: string[]; /** * Defines a custom validation rule for the object schema */ custom?: CustomValidator; }); get keys(): string[]; getFormDataFromState(state: FormSubmissionState): FormPayload; getFormValueFromState(state: FormSubmissionState): FormPayload; getStateFromValidForm(payload: FormPayload): Partial>; getContextValueFromState(state: FormSubmissionState): Partial>; /** * Get all errors for all fields in this collection */ getErrors(errors?: FormSubmissionError[]): FormSubmissionError[] | undefined; /** * Get view errors for all fields in this collection. * For most fields this means filtering to the first error in the list. * Composite fields like UKAddress can choose to return more than one error. */ getViewErrors(errors?: FormSubmissionError[]): FormSubmissionError[] | undefined; getViewModel(payload: FormPayload, errors?: FormSubmissionError[], query?: FormQuery): ComponentViewModel[]; /** * Validate form payload */ validate(value?: FormPayload): FormValidationResult; /** * Helper to get errors from all fields */ private getFieldErrors; } /** * Check for field local state */ export declare function isErrorContext(value?: unknown): value is ErrorReportCollection['local'];