import type { INotifyPropertiesChanged } from '../../viewModels'; import type { IValidatable } from '../IValidatable'; import type { IValidator, ValidatorCallback } from '../IValidator'; import type { IObjectValidator, IValidationTriggersSet } from './IObjectValidator'; import { type IObservableCollection } from '../../collections'; /** * Represents the object validator configuration. * @template TValidatable The instance type that is being validated. * @template TValidationError The concrete type for representing validation errors (strings, enums, numbers etc.). */ export interface IObjectValidatorConfig & INotifyPropertiesChanged, TValidationError = string> { readonly target: TValidatable; shouldTargetTriggerValidation?(target: TValidatable, changedProperties: readonly (keyof TValidatable)[]): boolean; } /** * Represents a base implementation for an object validator. * @template TValidatable The instance type that is being validated. * @template TValidationError The concrete type for representing validation errors (strings, enums, numbers etc.). */ export declare class ObjectValidator & INotifyPropertiesChanged, TValidationError = string> implements IObjectValidator { private static _defaultShouldTargetTriggerValidation; /** * Initializes a new instance of the {@linkcode ObjectValidator} class. * @param config The configuration to initialize the object validator with. */ constructor(config: IObjectValidatorConfig); /** * Gets the object that is being validated. */ readonly target: TValidatable; /** * Gets the validators that have been configured. */ readonly validators: IObservableCollection>; /** * Gets the validation triggers that have been configured. */ readonly triggers: IValidationTriggersSet; /** * Configures the given validators and validates the target afterwards. * @param validators The validators to add. * @returns Returns the current object validator. */ add(...validators: readonly (IValidator | ValidatorCallback)[]): this; /** * Validates the target using the currently configured validators. Validation does get triggered when the * target changes or when a trigger notifies that a validation should occur. * * Only use this method for specific cases where a validation need to be manually triggered, usually this * should not be the case. */ validate(): TValidationError | null; /** * Resets the validator configuraiton, removes all triggers and validators and sets the error on the target to `null`. */ reset(): this; }