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

Original URL: https://github.com/Andrei15193/react-model-view-viewmodel/wiki/useCollectionItemValidators
API / useCollectionItemValidators<TItem, TValidatableViewModel> hook

Registers and applies the provided validators to each item. The collection 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 just on that item and not the entire collection. This is useful when items have individual validation rules (e.g.: required value).

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

Template Parameters

Parameters