Added third option to determine if regex needs to match or not match.

Also fixed a bug where errors were overwriting eachother
This commit is contained in:
Josh Sherman 2013-09-08 14:31:55 -04:00
parent 94a9e08661
commit ae188a82a6
3 changed files with 10 additions and 10 deletions

View file

@ -425,13 +425,13 @@ class Module extends Object
// {{{ Checks using preg_match()
case 'regex':
if (count($rule) < 2)
if (count($rule) < 3)
{
throw new Exception('Invalid validation rule, expected: "regex:string".');
throw new Exception('Invalid validation rule, expected: "regex:is|not:string".');
}
else
{
if (preg_match($rule[1], $value))
if ((strtolower($rule[1]) == 'not' && !preg_match($rule[2], $value)) || preg_match($rule[2], $value))
{
$errors[] = $message;
}