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

API / registerCollectionItemValidators<TItem, TValidatableViewModel> function

Registers and applies the provided validators to each item and returns a clean-up callback.

The validators are applies 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 registerCollectionItemValidators<TItem, TValidatableViewModel extends IValidatable & INotifyPropertiesChanged>(collection: IReadOnlyObservableCollection<TItem>, selector: ValidatableSelectorCallback<TItem, TValidatableViewModel>, validators: readonly CollectionItemValidatorCallback<TValidatableViewModel, TItem>[]): UnsubscribeCallback
function registerCollectionItemValidators<TItem, TValidatableViewModel extends IValidatable & INotifyPropertiesChanged>(collection: IReadOnlyObservableCollection<TItem>, selector: ValidationConfigSelectorCallback<TItem, TValidatableViewModel>, validators: readonly CollectionItemValidatorCallback<TValidatableViewModel, TItem>[]): UnsubscribeCallback

Template Parameters

Parameters

Returns: UnsubscribeCallback

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