---
title: Custom validator registration
summary: Registers a non-control-bound validation rule using clsCustomValidator.
status: draft
owner: SAIF documentation team
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.Binding.Infragistics103
reference_type: embedded
operation_id: OP-BIND-005
trigger: Page code registering a validation rule not tied 1:1 to a simple control binding
---

# 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](register-control-binding.md)).
4. At `Validate()` time ([Validate bound controls](validate-bound-controls.md)), `clsCustomValidator.PerformValidation()` dispatches on `ValidationType`:
   - `Property`: invokes the caller's `PropertyValidator` delegate against `BindSource`/`BindProperty`/`ControlErrors`.
   - `Method`: invokes the caller's `CustomValidator` delegate against `Me` (the validator instance), setting `m_Errors = True` if it returns `False`.
   - `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.

```mermaid
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.*

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- `SAIF.Presentation.Web.Binding.Infragistics103\clsObjectBindManager.vb`
- `SAIF.Presentation.Web.Binding.Infragistics103\clsCustomValidator.vb`
