I'm trying to add a function to the from validation but is not working the validation is done and doesn't use the function checkPostalCode
public function build()
{
return array(
array(
'field' => 'postal_code',
'name' => 'Postal Code',
'rules' => 'trim|required|numeric|exact_length[5],callback_checkPostalCode',
'errors' => array(
'required' => trans('form.errors.required'),
'numeric' => trans('form.errors.numeric'),
'exact_length' => trans('form.errors.exact_length', array('%length%' => 5)),
)
)
);
}
public function checkPostalCode($pc){
if($pc == "08000")
return true;
else
return false;
}
The validation done on checkPostalCode is not working
try
'rules' => 'trim|required|numeric|exact_length[5]|callback_checkPostalCode',
instead of
'rules' => 'trim|required|numeric|exact_length[5],callback_checkPostalCode',