UNPKG

@uplink-protocol/form-controller

Version:

Reactive multi-step form controller with dynamic validation and state management

46 lines (45 loc) 1.72 kB
import { BaseService } from './base.service'; import { ConfigService } from './config.service'; import { FormService } from './form.service'; /** * Service for managing field validation and errors */ export declare class FieldService { private configService; private formService; private fieldErrorsService; private stepsValidityService; constructor(configService: ConfigService, formService: FormService, fieldErrorsService: BaseService<Record<string, Record<string, string>>>, stepsValidityService: BaseService<Record<string, boolean>>); /** * Validate a single field * @param stepId Step ID * @param fieldId Field ID * @param value Optional value to validate (defaults to current value in form data) * @param showErrors Whether to update the error state * @returns Validation result */ validateField(stepId: string, fieldId: string, value?: any, showErrors?: boolean): boolean; /** * Validate all fields in a step * @param stepId Step ID * @param showErrors Whether to update the error state * @returns Validation result */ validateStep(stepId: string, showErrors?: boolean): boolean; /** * Validate all steps in the form * @param showErrors Whether to update the error state * @returns Validation result */ validateForm(showErrors?: boolean): boolean; /** * Get the field errors service * @returns Field errors service */ getFieldErrorsService(): BaseService<Record<string, Record<string, string>>>; /** * Get the steps validity service * @returns Steps validity service */ getStepsValidityService(): BaseService<Record<string, boolean>>; }