When I use Laravel's string validation rule, what exactly is it doing? For example, does it simply run php's is_string()
method, or does it run filter_var()
perhaps, with the FILTER_VALIDATE_REGEXP
constant?
Secondly, how do I strip tags using Laravel?
When you use Laravel's string validation, the following function gets called
protected function validateAttribute($attribute, $rule) { ... }
which you could find in
vendor/laravel/framework/src/Illuminate/Validation/Validator.php
and if you examine the method, you'll find this piece of code
$method = "validate{$rule}";
if ($validatable && ! $this->$method($attribute, $value, $parameters, $this)) {
$this->addFailure($attribute, $rule, $parameters);
}
which would call the trait Concerns\ValidatesAttributes
/**
* Validate that an attribute is a string.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function validateString($attribute, $value)
{
return is_string($value);
}
and to strip tags you could use PHP's strip_tags
method
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments