Add email validators

This commit is contained in:
unknown 2011-05-03 19:08:10 +04:00
parent d562f6fa69
commit f98843b6cf
2 changed files with 33 additions and 0 deletions

View file

@ -0,0 +1,17 @@
<?php
namespace Respect\Validation\Exceptions;
class EmailException extends ValidationException
{
public static $defaultTemplates = array(
self::MODE_DEFAULT => array(
self::STANDARD => '{{name}} must be valid email',
),
self::MODE_NEGATIVE => array(
self::STANDARD => '{{name}} must not be email',
)
);
}

View file

@ -0,0 +1,16 @@
<?php
namespace Respect\Validation\Rules;
class Email extends AbstractRule
{
public function validate($input)
{
if (!is_string($input)) {
return false;
}
return filter_var($input, FILTER_VALIDATE_EMAIL);
}
}