From e963ad84d59daabd5fedc2b86f874e13e453dea7 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Mon, 16 Aug 2021 16:06:27 -0400 Subject: [PATCH] Add default param to attribute response models --- src/Appwrite/Utopia/Response/Model/AttributeBoolean.php | 8 ++++++++ src/Appwrite/Utopia/Response/Model/AttributeEmail.php | 8 ++++++++ src/Appwrite/Utopia/Response/Model/AttributeFloat.php | 8 ++++++++ src/Appwrite/Utopia/Response/Model/AttributeIP.php | 8 ++++++++ src/Appwrite/Utopia/Response/Model/AttributeInteger.php | 8 ++++++++ src/Appwrite/Utopia/Response/Model/AttributeString.php | 8 ++++++++ src/Appwrite/Utopia/Response/Model/AttributeURL.php | 8 ++++++++ 7 files changed, 56 insertions(+) diff --git a/src/Appwrite/Utopia/Response/Model/AttributeBoolean.php b/src/Appwrite/Utopia/Response/Model/AttributeBoolean.php index 70c089e511..93979288ea 100644 --- a/src/Appwrite/Utopia/Response/Model/AttributeBoolean.php +++ b/src/Appwrite/Utopia/Response/Model/AttributeBoolean.php @@ -10,6 +10,14 @@ class AttributeBoolean extends Model public function __construct() { $this + ->addRule('default', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Default value for attribute when not provided. Cannot be set when attribute is required.', + 'default' => null, + 'example' => false, + 'array' => false, + 'required' => false, + ]) ; } diff --git a/src/Appwrite/Utopia/Response/Model/AttributeEmail.php b/src/Appwrite/Utopia/Response/Model/AttributeEmail.php index b0ea0d730f..11d068e8fa 100644 --- a/src/Appwrite/Utopia/Response/Model/AttributeEmail.php +++ b/src/Appwrite/Utopia/Response/Model/AttributeEmail.php @@ -18,6 +18,14 @@ class AttributeEmail extends AttributeString 'array' => false, 'required' => true, ]) + ->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, + 'required' => false, + ]) ; } diff --git a/src/Appwrite/Utopia/Response/Model/AttributeFloat.php b/src/Appwrite/Utopia/Response/Model/AttributeFloat.php index 3320582b5c..66259cfdb3 100644 --- a/src/Appwrite/Utopia/Response/Model/AttributeFloat.php +++ b/src/Appwrite/Utopia/Response/Model/AttributeFloat.php @@ -26,6 +26,14 @@ class AttributeFloat extends Attribute 'array' => false, 'required' => false, ]) + ->addRule('default', [ + 'type' => self::TYPE_FLOAT, + 'description' => 'Default value for attribute when not provided. Cannot be set when attribute is required.', + 'default' => null, + 'example' => 2.5, + 'array' => false, + 'required' => false, + ]) ; } diff --git a/src/Appwrite/Utopia/Response/Model/AttributeIP.php b/src/Appwrite/Utopia/Response/Model/AttributeIP.php index 19147ce00b..a380e6e4d7 100644 --- a/src/Appwrite/Utopia/Response/Model/AttributeIP.php +++ b/src/Appwrite/Utopia/Response/Model/AttributeIP.php @@ -18,6 +18,14 @@ class AttributeIP extends AttributeString 'array' => false, 'required' => true, ]) + ->addRule('default', [ + 'type' => self::TYPE_STRING, + 'description' => 'Default value for attribute when not provided. Cannot be set when attribute is required.', + 'default' => null, + 'example' => '192.0.2.0', + 'array' => false, + 'required' => false, + ]) ; } diff --git a/src/Appwrite/Utopia/Response/Model/AttributeInteger.php b/src/Appwrite/Utopia/Response/Model/AttributeInteger.php index ee65d3a397..3092a71453 100644 --- a/src/Appwrite/Utopia/Response/Model/AttributeInteger.php +++ b/src/Appwrite/Utopia/Response/Model/AttributeInteger.php @@ -26,6 +26,14 @@ class AttributeInteger extends Attribute 'array' => false, 'required' => false, ]) + ->addRule('default', [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Default value for attribute when not provided. Cannot be set when attribute is required.', + 'default' => null, + 'example' => 10, + 'array' => false, + 'required' => false, + ]) ; } diff --git a/src/Appwrite/Utopia/Response/Model/AttributeString.php b/src/Appwrite/Utopia/Response/Model/AttributeString.php index e7eb558b61..29a86a4b24 100644 --- a/src/Appwrite/Utopia/Response/Model/AttributeString.php +++ b/src/Appwrite/Utopia/Response/Model/AttributeString.php @@ -16,6 +16,14 @@ class AttributeString extends Attribute 'default' => 0, 'example' => 128, ]) + ->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', + 'array' => false, + 'required' => false, + ]) ; } diff --git a/src/Appwrite/Utopia/Response/Model/AttributeURL.php b/src/Appwrite/Utopia/Response/Model/AttributeURL.php index d310af131a..52a549e2a1 100644 --- a/src/Appwrite/Utopia/Response/Model/AttributeURL.php +++ b/src/Appwrite/Utopia/Response/Model/AttributeURL.php @@ -18,6 +18,14 @@ class AttributeURL extends AttributeString 'array' => false, 'required' => true, ]) + ->addRule('default', [ + 'type' => self::TYPE_STRING, + 'description' => 'Default value for attribute when not provided. Cannot be set when attribute is required.', + 'default' => null, + 'example' => 'http://example.com', + 'array' => false, + 'required' => false, + ]) ; }