mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Changed rule structure
This commit is contained in:
@@ -33,13 +33,15 @@ abstract class Result
|
||||
/**
|
||||
* Add a New Rule
|
||||
*/
|
||||
protected function addRule(string $key, string $type, string $description, string $example): self
|
||||
protected function addRule(string $key, array $options): self
|
||||
{
|
||||
$this->rules[$key] = [
|
||||
'type' => $type,
|
||||
'description' => $description,
|
||||
'example' => $example,
|
||||
];
|
||||
$this->rules[$key] = array_merge([
|
||||
'type' => '',
|
||||
'description' => '',
|
||||
'default' => null,
|
||||
'example' => '',
|
||||
'array' => false,
|
||||
], $options);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -10,11 +10,42 @@ class User extends Result
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->addRule('$id', 'string', 'User ID.', '5e5ea5c16897e')
|
||||
->addRule('name', 'string', 'User name.', 'John Doe')
|
||||
->addRule('email', 'string', 'User email address.', 'john@appwrite.io')
|
||||
->addRule('emailVerification', 'string', 'Email verification status.', true)
|
||||
->addRule('registration', 'integer', 'User registration date in UNIX format.', 1583261121)
|
||||
->addRule('$id', [
|
||||
'type' => 'string',
|
||||
'description' => 'User ID.',
|
||||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('name', [
|
||||
'type' => 'string',
|
||||
'description' => 'User name.',
|
||||
'default' => '',
|
||||
'example' => 'John Doe',
|
||||
])
|
||||
->addRule('email', [
|
||||
'type' => 'string',
|
||||
'description' => 'User email address.',
|
||||
'default' => '',
|
||||
'example' => 'john@appwrite.io',
|
||||
])
|
||||
->addRule('emailVerification', [
|
||||
'type' => 'boolean',
|
||||
'description' => 'Email verification status.',
|
||||
'default' => false,
|
||||
'example' => true,
|
||||
])
|
||||
->addRule('prefs', [
|
||||
'type' => 'json',
|
||||
'description' => 'User preferences as a key-value object',
|
||||
'default' => new \stdClass,
|
||||
'example' => ['theme' => 'dark', 'timezone' => 'UTC'],
|
||||
])
|
||||
->addRule('roles', [
|
||||
'type' => 'string',
|
||||
'description' => 'User list of roles',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user