registerValidators - Andrei15193/react-model-view-viewmodel Wiki

API / registerValidators<TValidatableViewModel> function

Registers and applies the provided validators returning a clean-up callback.

The validators are applied one after the other until the first one returns an error message (a value different from undefined).

Whenever a property has changed (except for error, isValid and isInvalid) on the validatable, a new validation is performed.

function registerValidators<TValidatableViewModel extends IValidatable & INotifyPropertiesChanged>(validatable: TValidatableViewModel, validators: readonly ValidatorCallback<TValidatableViewModel>[]): UnsubscribeCallback
function registerValidators<TValidatableViewModel extends IValidatable & INotifyPropertiesChanged>(validatableConfig: IValidationConfig<TValidatableViewModel>, validators: readonly ValidatorCallback<TValidatableViewModel>[]): UnsubscribeCallback

Template Parameters

Parameters

Returns: UnsubscribeCallback

Returns a clean-up callback that unsubscribes all event registrations.