Here is the custom validation I made to validate a string. My question is how to pass a variable (i.e. missing_tags) into the error message? Thanks.
Validator::extend('tags', function($attribute, $value, $parameters, $validator) {
$tags = explode(',', $value);
$missing_tags = array()
foreach ($tags as $tag)
{
if (!Tag::exist($tag))
{
$missing_tags[] = $tag;
}
}
return count($missing_tags) == 0;
});
Validator::replacer('tags', function($message, $attribute, $rule, $parameters)
{
return str_replace('missing_tags', $missing_tags, $message);
});