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

API / useValidators<TValidatableViewModel> hook

Registers and applies the provided validators. The validatable and validators are part of the dependencies.

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 useValidators<TValidatableViewModel extends IValidatable & INotifyPropertiesChanged>(validatable: TValidatableViewModel, validators: readonly ValidatorCallback<TValidatableViewModel>[]): void
function useValidators<TValidatableViewModel extends IValidatable & INotifyPropertiesChanged>(validationConfig: IValidationConfig<TValidatableViewModel>, validators: readonly ValidatorCallback<TValidatableViewModel>[]): void

Template Parameters

Parameters