Custom validator

DatDat
edited March 2011 in Modules
How do I create a custom validator for the validator class?
$this->validator->add_rule('field', 'func', 'msg', 'params')

I can insert my own function within the validator helper but I don't want to put it in there if I'm only going to use it once. Help?

Comments

  • edited 2:34AM
    If it is specific to say a model, then sometimes I'll add the validation function on the model and instead of the function name I'll use array($this, 'my_func'). However, you can use the create_funciton() php function to create a lamda function.
    http://php.net/manual/en/function.create-function.php
  • DatDat
    edited 2:34AM
    Alright thanks I'll use the array($this, 'my_function')!
Sign In or Register to comment.