68 lines
1.1 KiB
PHP
68 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Appwrite\Network\Validator;
|
|
|
|
use Utopia\Validator;
|
|
|
|
/**
|
|
* Email
|
|
*
|
|
* Validate that an variable is a valid email address
|
|
*
|
|
* @package Utopia\Validator
|
|
*/
|
|
class Email extends Validator
|
|
{
|
|
/**
|
|
* Get Description
|
|
*
|
|
* Returns validator description
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getDescription(): string
|
|
{
|
|
return 'Value must be a valid email address';
|
|
}
|
|
|
|
/**
|
|
* Is valid
|
|
*
|
|
* Validation will pass when $value is valid email address.
|
|
*
|
|
* @param mixed $value
|
|
* @return bool
|
|
*/
|
|
public function isValid($value): bool
|
|
{
|
|
if (!\filter_var($value, FILTER_VALIDATE_EMAIL)) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Is array
|
|
*
|
|
* Function will return true if object is array.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function isArray(): bool
|
|
{
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Get Type
|
|
*
|
|
* Returns validator type.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getType(): string
|
|
{
|
|
return self::TYPE_STRING;
|
|
}
|
|
}
|