Skip to content

Custom validator registration

This operation registers a clsCustomValidator binder that supports validation scenarios beyond a simple property-to-control binding, dispatching to a caller-supplied delegate or to the bound object's own IsValid property.

Field Value
Operation ID OP-BIND-005
Trigger Page code calling AddCustomValidator(target), AddCustomValidator(target, keyProperty, propertyValidator), or AddCustomValidator(control, target, validationMethod) on clsObjectBindManager
Inputs Bound target object; optional key property + PropertyValidator delegate; optional control + CustomValidator delegate
Outputs A clsCustomValidator binder appended via AddBinder()
Primary components clsObjectBindManager.AddCustomValidator, clsCustomValidator.PerformValidation
Entry point SAIF.Presentation.Web.Binding.Infragistics103\clsObjectBindManager.vb

Steps

  1. Construct New clsCustomValidator.
  2. Set BindSource/BindProperty and ValidationType (Object, Property, or Method, depending on the overload used), and the corresponding delegate property (PropertyValidationDelegate or MethodValidationDelegate).
  3. Call AddBinder() (same registration logic as the standard Add() family — see Register and initialize a control binding).
  4. At Validate() time (Validate bound controls), clsCustomValidator.PerformValidation() dispatches on ValidationType:
  5. Property: invokes the caller's PropertyValidator delegate against BindSource/BindProperty/ControlErrors.
  6. Method: invokes the caller's CustomValidator delegate against Me (the validator instance), setting m_Errors = True if it returns False.
  7. Object: reflectively reads IsValid on the bound SAIF framework object (only if IsSAIFFrameWorkObject() is true).

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start([AddCustomValidator called]) --> Construct[Construct clsCustomValidator]
    Construct --> SetProps[Set BindSource, BindProperty, ValidationType, delegate]
    SetProps --> AddBinder[AddBinder: register in m_Bindings]
    AddBinder --> Later[At Validate time: PerformValidation dispatches]
    Later --> Mode{ValidationType?}
    Mode -->|Property| PropDelegate[Invoke PropertyValidator delegate]
    Mode -->|Method| MethodDelegate[Invoke CustomValidator delegate]
    Mode -->|Object| ObjectCheck[Reflectively read IsValid if SAIF framework object]
    PropDelegate --> EndOk([Validation result contributes to overall Validate result])
    MethodDelegate --> EndOk
    ObjectCheck --> EndOk

Failure and edge-case behavior

  • For ValidationType.Object, if the bound object is not recognized as a SAIF framework object (IsSAIFFrameWorkObject() returns false), no IsValid check is performed and the validator effectively contributes no error.*

Sources

  • SAIF.Presentation.Web.Binding.Infragistics103\clsObjectBindManager.vb
  • SAIF.Presentation.Web.Binding.Infragistics103\clsCustomValidator.vb