How to use a static class method as a filter for Kohana's Validation Library?

Kohana's Validation library has a pre_filter() method which lets you apply any PHP function to fields to be validated, as trim(), etc. I tried to use a static method as a filter, but won't work: $validation->pre_filter( 'field_name', 'class::method' )

What that does is create two filters, one with class and antoher one with method.

Any clues?


A callback is one of PHP's pseudo-types. It will let you pass a

  1. function
  2. method of an instantiated object
  3. static method/class method

to a PHP function/method that's expecting a callback, and the PHP function/method will know what to do with it.

From the manual

A PHP function is passed by its name as a string. Any built-in or user-defined function can be used, except language constructs such as: array(), echo(), empty(), eval(), exit(), isset(), list(), print() or unset().

A method of an instantiated object is passed as an array containing an object at index 0 and the method name at index 1.

Static class methods can also be passed without instantiating an object of that class by passing the class name instead of an object at index 0.

So, to use a static method in place of a callback string, you'd use


If Kohana is using standard PHP callbacks, this should give you what you want.

Need Your Help

how come in VB.NET a listcontrol has no Items collection but in ASP.NET it does? listcontrol itemscollection

I have a simple subroutine that loads a list from a database. I would like to be able to use the same code to load a ListBox and a ComboBox by defining the list type as the common abstract base class