2021-08-13 20:57:08 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Appwrite\Utopia\Response\Model;
|
|
|
|
|
|
|
|
|
|
use Appwrite\Utopia\Response;
|
|
|
|
|
|
|
|
|
|
class AttributeFloat extends Attribute
|
|
|
|
|
{
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
2021-08-24 14:31:02 +00:00
|
|
|
parent::__construct();
|
|
|
|
|
|
2021-08-13 20:57:08 +00:00
|
|
|
$this
|
2022-03-14 06:03:55 +00:00
|
|
|
->addRule('key', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'Attribute Key.',
|
|
|
|
|
'default' => '',
|
2022-03-14 17:40:19 +00:00
|
|
|
'example' => 'percentageCompleted',
|
2022-03-14 06:03:55 +00:00
|
|
|
])
|
|
|
|
|
->addRule('type', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'Attribute type.',
|
|
|
|
|
'default' => '',
|
|
|
|
|
'example' => 'double',
|
|
|
|
|
])
|
2021-08-24 18:01:53 +00:00
|
|
|
->addRule('min', [
|
2021-08-27 20:27:59 +00:00
|
|
|
'type' => self::TYPE_FLOAT,
|
2021-08-24 18:01:53 +00:00
|
|
|
'description' => 'Minimum value to enforce for new documents.',
|
|
|
|
|
'default' => null,
|
2022-09-02 23:19:20 +00:00
|
|
|
'required' => false,
|
2021-08-27 20:27:59 +00:00
|
|
|
'example' => 1.5,
|
2021-08-24 18:01:53 +00:00
|
|
|
])
|
|
|
|
|
->addRule('max', [
|
2021-08-27 20:27:59 +00:00
|
|
|
'type' => self::TYPE_FLOAT,
|
2021-08-24 18:01:53 +00:00
|
|
|
'description' => 'Maximum value to enforce for new documents.',
|
2021-08-13 20:57:08 +00:00
|
|
|
'default' => null,
|
2022-09-02 23:19:20 +00:00
|
|
|
'required' => false,
|
2021-08-27 20:27:59 +00:00
|
|
|
'example' => 10.5,
|
2021-08-13 20:57:08 +00:00
|
|
|
])
|
2021-08-16 20:06:27 +00:00
|
|
|
->addRule('default', [
|
|
|
|
|
'type' => self::TYPE_FLOAT,
|
|
|
|
|
'description' => 'Default value for attribute when not provided. Cannot be set when attribute is required.',
|
|
|
|
|
'default' => null,
|
2022-09-02 23:19:20 +00:00
|
|
|
'required' => false,
|
2021-08-16 20:06:27 +00:00
|
|
|
'example' => 2.5,
|
|
|
|
|
])
|
2021-08-13 20:57:08 +00:00
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-14 08:26:16 +00:00
|
|
|
public array $conditions = [
|
|
|
|
|
'type' => self::TYPE_FLOAT,
|
|
|
|
|
];
|
|
|
|
|
|
2021-08-13 20:57:08 +00:00
|
|
|
/**
|
|
|
|
|
* Get Name
|
2022-05-23 14:54:50 +00:00
|
|
|
*
|
2021-08-13 20:57:08 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2022-05-23 14:54:50 +00:00
|
|
|
public function getName(): string
|
2021-08-13 20:57:08 +00:00
|
|
|
{
|
2021-08-16 19:59:58 +00:00
|
|
|
return 'AttributeFloat';
|
2021-08-13 20:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-09-15 15:17:09 +00:00
|
|
|
* Get Type
|
2022-05-23 14:54:50 +00:00
|
|
|
*
|
2021-08-13 20:57:08 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2022-05-23 14:54:50 +00:00
|
|
|
public function getType(): string
|
2021-08-13 20:57:08 +00:00
|
|
|
{
|
2021-08-16 19:59:58 +00:00
|
|
|
return Response::MODEL_ATTRIBUTE_FLOAT;
|
2021-08-13 20:57:08 +00:00
|
|
|
}
|
2022-05-23 14:54:50 +00:00
|
|
|
}
|