mirror of
https://github.com/Respect/Validation.git
synced 2024-06-29 02:30:06 +02:00
Add email validators
This commit is contained in:
parent
d562f6fa69
commit
f98843b6cf
17
library/Respect/Validation/Exceptions/EmailException.php
Normal file
17
library/Respect/Validation/Exceptions/EmailException.php
Normal 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',
|
||||
)
|
||||
);
|
||||
|
||||
}
|
16
library/Respect/Validation/Rules/Email.php
Normal file
16
library/Respect/Validation/Rules/Email.php
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue