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

API / useCollectionValidators<TItem, 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 on the entire collection. Each item is revalidated, this is useful when items must have a unique value.

function useCollectionValidators<TItem, TValidatableViewModel extends IValidatable & INotifyPropertiesChanged>(collection: IReadOnlyObservableCollection<TItem>, selector: ValidatableSelectorCallback<TItem, TValidatableViewModel>, validators: readonly (CollectionItemValidatorCallback<TValidatableViewModel, TItem> | undefined)[]): void
function useCollectionValidators<TItem, TValidatableViewModel extends IValidatable & INotifyPropertiesChanged>(collection: IReadOnlyObservableCollection<TItem>, selector: ValidationConfigSelectorCallback<TItem, TValidatableViewModel>, validators: readonly (CollectionItemValidatorCallback<TValidatableViewModel, TItem> | undefined)[]): void

Template Parameters

Parameters