2020-10-30 02:07:56 +13:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Appwrite\Utopia\Response\Model;
|
|
|
|
|
|
|
|
use Appwrite\Utopia\Response;
|
|
|
|
use Appwrite\Utopia\Response\Model;
|
|
|
|
|
|
|
|
class Rule extends Model
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this
|
|
|
|
->addRule('$id', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Rule ID.',
|
2021-01-14 04:06:36 +13:00
|
|
|
'default' => '',
|
2020-10-30 02:07:56 +13:00
|
|
|
'example' => '5e5ea5c16897e',
|
|
|
|
])
|
|
|
|
->addRule('$collection', [ // TODO remove this from public response
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Rule Collection.',
|
|
|
|
'example' => '5e5e66c16897e',
|
|
|
|
])
|
|
|
|
->addRule('type', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Rule type. Possible values: ',
|
2021-01-14 04:06:36 +13:00
|
|
|
'default' => '',
|
2020-10-30 02:07:56 +13:00
|
|
|
'example' => 'title',
|
|
|
|
])
|
|
|
|
->addRule('key', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Rule key.',
|
2021-01-14 04:06:36 +13:00
|
|
|
'default' => '',
|
2020-10-30 02:07:56 +13:00
|
|
|
'example' => 'title',
|
|
|
|
])
|
|
|
|
->addRule('label', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Rule label.',
|
2021-01-14 04:06:36 +13:00
|
|
|
'default' => '',
|
2020-10-30 02:07:56 +13:00
|
|
|
'example' => 'Title',
|
|
|
|
])
|
|
|
|
->addRule('default', [ // TODO should be of mixed types
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Rule default value.',
|
|
|
|
'default' => '',
|
2021-01-14 04:06:36 +13:00
|
|
|
'example' => 'Movie Name',
|
2020-10-30 02:07:56 +13:00
|
|
|
])
|
|
|
|
->addRule('array', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_BOOLEAN,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Is array?',
|
2021-01-14 04:06:36 +13:00
|
|
|
'default' => false,
|
2020-10-30 02:07:56 +13:00
|
|
|
'example' => false,
|
|
|
|
])
|
|
|
|
->addRule('required', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_BOOLEAN,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'Is required?',
|
2021-01-14 04:06:36 +13:00
|
|
|
'default' => false,
|
2020-10-30 02:07:56 +13:00
|
|
|
'example' => true,
|
|
|
|
])
|
|
|
|
->addRule('list', [
|
2020-11-08 11:14:48 +13:00
|
|
|
'type' => self::TYPE_STRING,
|
2020-10-30 02:07:56 +13:00
|
|
|
'description' => 'List of allowed values',
|
|
|
|
'array' => true,
|
|
|
|
'default' => [],
|
2021-02-02 10:31:54 +13:00
|
|
|
'example' => '5e5ea5c168099',
|
2020-10-30 02:07:56 +13:00
|
|
|
])
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Name
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getName():string
|
|
|
|
{
|
|
|
|
return 'Rule';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Collection
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getType():string
|
|
|
|
{
|
|
|
|
return Response::MODEL_RULE;
|
|
|
|
}
|
|
|
|
}
|