Wixel/GUMP — Issue #6: Validator method '$method' does not exist.
Author: ben-s
Created: 2012-01-17 13:07:43+00:00
State: open

I'm trying to create my create your class that extends the GUMP class, but I can't get my FormValidation::vaildate() method working.

I added my own validate method :

require_once('gump.class.php');

class FormValidation extends GUMP
{
public static function validate_alpha_dash_space_apo($field, $input, $param = NULL)
{
if(!isset($input[$field]))
{
return;
}

if(!preg_match("/^([-a-zÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïñðòóôõöùúûüýÿ '-])+$/i", $input[$field]) !== FALSE)
{
return array(
'field' => $field,
'value' => $input[$field],
'rule'	=> __FUNCTION__
);
}
}
}

The thing is, If I don't copy/paste the gump "validate" method in my own class, I get the following message :
"Fatal error: Uncaught exception 'Exception' with message 'Validator method 'validate_alpha_dash_space_apo' does not exist.' in gump.class.php:150 Stack trace: #0 index.php(129): GUMP::validate(Array, Array) #1 {main} thrown in gump.class.php on line 150 "

My PHP code used to valiate my form is quite simple :

'required',
'firstname' => 'required|alpha_dash_space_apo',
'lastname' => 'required|alpha_dash_space_apo',
);

$valid = FormValidation::validate($_POST, $rules); // This is the line n°129 in index.php pointed by the PHP error message above

}
?>

Is there anything more I should do compared to the tutorial on your github page in order to create my own validators ?

Regards