Click or drag to resize

ElementValidatorTValidateAsync Method (ValidationContextT)

Validates an element context asynchronously and determines if the element is valid.

Namespace:  Xploration.Validation
Assembly:  Xploration.Validation (in Xploration.Validation.dll) Version: 1.0.0-alpha1
protected abstract Task<bool> ValidateAsync(
	ValidationContext<T> context


Type: Xploration.ValidationValidationContextT
An element context that contains an element from the collection.

The index of the element context is set to the element its index in the collection. See Index

Return Value

Type: TaskBoolean
True if the given element context is valid, otherwise false.
Important note Important
Implementers are required to register validation results to the context. If an Error object is not included with the validation result the current instance will try to supply one with the help of the ErrorProvider.

For each element in the old and new collection of the main context this method gets called. The number of times the method gets called is equal to the length of the largest collection(Old or NewValue) in the main context.

A new element context is created for each call where the old and new value of this context are set to an element from the old and new collection. Since the old and new collection can differ in length a value of default(T) will be used for a missing element. The index of the element under validation is also set on the new element context. For each call the element context its values and index are set according to the table below.

Important note Important
This method will only work correctly if the old and new collection of the main context are properly sorted.

Collection contextElement context
Old collection[]New collection[]IndexOld elementNew element
Length 0Length 2
Length 1Length 3
Length 3Length 1
Length 2Length 0

See Also