Commit 52091bda authored by Taylor Otwell's avatar Taylor Otwell

Added "match" validation rule for regular expression checks.

parent afb33c17
...@@ -36,6 +36,7 @@ return array( ...@@ -36,6 +36,7 @@ return array(
"in" => "The selected :attribute is invalid.", "in" => "The selected :attribute is invalid.",
"integer" => "The :attribute must be an integer.", "integer" => "The :attribute must be an integer.",
"ip" => "The :attribute must be a valid IP address.", "ip" => "The :attribute must be a valid IP address.",
"match" => "The :attribute format is invalid.",
"max" => array( "max" => array(
"numeric" => "The :attribute must be less than :max.", "numeric" => "The :attribute must be less than :max.",
"file" => "The :attribute must be less than :max kilobytes.", "file" => "The :attribute must be less than :max kilobytes.",
......
...@@ -611,6 +611,18 @@ class Validator { ...@@ -611,6 +611,18 @@ class Validator {
return preg_match('/^([-a-z0-9_-])+$/i', $value); return preg_match('/^([-a-z0-9_-])+$/i', $value);
} }
/**
* Validate that an attribute passes a regular expression check.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
protected function validate_match($attribute, $value, $parameters)
{
return preg_match($parameters[0], $value);
}
/** /**
* Validate the MIME type of a file upload attribute is in a set of MIME types. * Validate the MIME type of a file upload attribute is in a set of MIME types.
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment