2021-08-14 08:58:36 +12:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Appwrite\Utopia\Response\Model;
|
|
|
|
|
|
|
|
use Appwrite\Utopia\Response;
|
2021-08-28 08:24:48 +12:00
|
|
|
use Appwrite\Utopia\Response\Model\Attribute;
|
2021-08-14 08:58:36 +12:00
|
|
|
|
2021-08-28 08:24:48 +12:00
|
|
|
class AttributeEmail extends Attribute
|
2021-08-14 08:58:36 +12:00
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
2021-08-25 02:31:02 +12:00
|
|
|
parent::__construct();
|
|
|
|
|
2021-08-14 08:58:36 +12:00
|
|
|
$this
|
|
|
|
->addRule('format', [
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
'description' => 'String format.',
|
2021-08-24 09:25:32 +12:00
|
|
|
'default' => APP_DATABASE_ATTRIBUTE_EMAIL,
|
|
|
|
'example' => APP_DATABASE_ATTRIBUTE_EMAIL,
|
2021-08-14 08:58:36 +12:00
|
|
|
'array' => false,
|
2021-08-17 10:59:33 +12:00
|
|
|
'require' => true,
|
2021-08-14 08:58:36 +12:00
|
|
|
])
|
2021-08-17 08:06:27 +12:00
|
|
|
->addRule('default', [
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
'description' => 'Default value for attribute when not provided. Cannot be set when attribute is required.',
|
|
|
|
'default' => null,
|
|
|
|
'example' => 'default@example.com',
|
|
|
|
'array' => false,
|
2021-08-17 10:59:33 +12:00
|
|
|
'require' => false,
|
2021-08-17 08:06:27 +12:00
|
|
|
])
|
2021-08-14 08:58:36 +12:00
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2021-09-14 20:26:16 +12:00
|
|
|
public array $conditions = [
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
'format' => \APP_DATABASE_ATTRIBUTE_EMAIL
|
|
|
|
];
|
|
|
|
|
2021-08-14 08:58:36 +12:00
|
|
|
/**
|
|
|
|
* Get Name
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getName():string
|
|
|
|
{
|
2021-08-17 07:54:25 +12:00
|
|
|
return 'AttributeEmail';
|
2021-08-14 08:58:36 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-09-16 03:17:09 +12:00
|
|
|
* Get Type
|
2021-08-14 08:58:36 +12:00
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getType():string
|
|
|
|
{
|
2021-08-17 07:54:25 +12:00
|
|
|
return Response::MODEL_ATTRIBUTE_EMAIL;
|
2021-08-14 08:58:36 +12:00
|
|
|
}
|
|
|
|
}
|