[eluser]nuwanda[/eluser]
In my extended validation class I have:
Code:
function valid_url($url){
$pattern = '/' . '^(https?:\/\/)[^\s]+$' . '/';
preg_match($pattern, $url, $matches);
return (empty($matches)) ? FALSE : TRUE;
}
That returns false if the submitted url fails a regex. It works fine.
But my goal is to let the user know *why* the url fails.
The idea is to fail the test but also to return a validation error as to why it failed. I'd like to set a validation error message.
I can't, obviously, because I can only return true or false to the rule. Setting a validation error at this point is not valid because my scope is in the validation class, not the model that holds the rules.
In my model, I have a rule:
Code:
$this->form_validation->set_rules('link_url','link url','valid_url');