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

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

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