set_caller()

public function set_caller(object $caller): void

Description

Sets the calling controller instance, enabling callback validation rules. Callback rules allow you to define custom validation logic in your controller methods.

The Validation module automatically sets the caller when instantiated via $this->validation. You only need to call this method manually when creating Validation instances programmatically.

Parameters

Parameter Type Description
$caller object The controller instance that contains callback methods.

Return Value

Type Description
void This method does not return a value.

Example Usage

Notes

  • Callback methods must be public and return true (validation passed) or false (validation failed).
  • Callback method names in rules must be prefixed with callback_ (e.g., callback_check_unique).
  • The callback method receives the field value as its only parameter.
  • If a callback returns false, a generic error "Validation failed for {field}" is added.