Explicitly add attribute model rules

This commit is contained in:
kodumbeats 2021-08-23 17:25:32 -04:00
parent 19e1443469
commit 0eb0ceb6d5
7 changed files with 223 additions and 6 deletions

View file

@ -10,6 +10,37 @@ class AttributeBoolean extends Model
public function __construct()
{
$this
->addRule('key', [
'type' => self::TYPE_STRING,
'description' => 'Attribute Key.',
'default' => '',
'example' => 'fullName',
])
->addRule('type', [
'type' => self::TYPE_STRING,
'description' => 'Attribute type.',
'default' => '',
'example' => 'string',
])
->addRule('status', [
'type' => self::TYPE_STRING,
'description' => 'Attribute status. Possible values: `available`, `processing`, `deleting`, or `failed`',
'default' => '',
'example' => 'string',
])
->addRule('required', [
'type' => self::TYPE_BOOLEAN,
'description' => 'Is attribute required?',
'default' => false,
'example' => true,
])
->addRule('array', [
'type' => self::TYPE_BOOLEAN,
'description' => 'Is attribute an array?',
'default' => false,
'example' => false,
'require' => false
])
->addRule('default', [
'type' => self::TYPE_BOOLEAN,
'description' => 'Default value for attribute when not provided. Cannot be set when attribute is required.',

View file

@ -10,11 +10,42 @@ class AttributeEmail extends AttributeString
public function __construct()
{
$this
->addRule('key', [
'type' => self::TYPE_STRING,
'description' => 'Attribute Key.',
'default' => '',
'example' => 'fullName',
])
->addRule('type', [
'type' => self::TYPE_STRING,
'description' => 'Attribute type.',
'default' => '',
'example' => 'string',
])
->addRule('status', [
'type' => self::TYPE_STRING,
'description' => 'Attribute status. Possible values: `available`, `processing`, `deleting`, or `failed`',
'default' => '',
'example' => 'string',
])
->addRule('required', [
'type' => self::TYPE_BOOLEAN,
'description' => 'Is attribute required?',
'default' => false,
'example' => true,
])
->addRule('array', [
'type' => self::TYPE_BOOLEAN,
'description' => 'Is attribute an array?',
'default' => false,
'example' => false,
'require' => false
])
->addRule('format', [
'type' => self::TYPE_STRING,
'description' => 'String format.',
'default' => \json_encode(['name'=>APP_DATABASE_ATTRIBUTE_EMAIL]),
'example' => \json_encode(['name'=>APP_DATABASE_ATTRIBUTE_EMAIL]),
'default' => APP_DATABASE_ATTRIBUTE_EMAIL,
'example' => APP_DATABASE_ATTRIBUTE_EMAIL,
'array' => false,
'require' => true,
])

View file

@ -10,6 +10,37 @@ class AttributeFloat extends Attribute
public function __construct()
{
$this
->addRule('key', [
'type' => self::TYPE_STRING,
'description' => 'Attribute Key.',
'default' => '',
'example' => 'fullName',
])
->addRule('type', [
'type' => self::TYPE_STRING,
'description' => 'Attribute type.',
'default' => '',
'example' => 'string',
])
->addRule('status', [
'type' => self::TYPE_STRING,
'description' => 'Attribute status. Possible values: `available`, `processing`, `deleting`, or `failed`',
'default' => '',
'example' => 'string',
])
->addRule('required', [
'type' => self::TYPE_BOOLEAN,
'description' => 'Is attribute required?',
'default' => false,
'example' => true,
])
->addRule('array', [
'type' => self::TYPE_BOOLEAN,
'description' => 'Is attribute an array?',
'default' => false,
'example' => false,
'require' => false
])
->addRule('format', [
'type' => self::TYPE_FLOAT,
'description' => 'Float format.',

View file

@ -10,11 +10,42 @@ class AttributeIP extends AttributeString
public function __construct()
{
$this
->addRule('key', [
'type' => self::TYPE_STRING,
'description' => 'Attribute Key.',
'default' => '',
'example' => 'fullName',
])
->addRule('type', [
'type' => self::TYPE_STRING,
'description' => 'Attribute type.',
'default' => '',
'example' => 'string',
])
->addRule('status', [
'type' => self::TYPE_STRING,
'description' => 'Attribute status. Possible values: `available`, `processing`, `deleting`, or `failed`',
'default' => '',
'example' => 'string',
])
->addRule('required', [
'type' => self::TYPE_BOOLEAN,
'description' => 'Is attribute required?',
'default' => false,
'example' => true,
])
->addRule('array', [
'type' => self::TYPE_BOOLEAN,
'description' => 'Is attribute an array?',
'default' => false,
'example' => false,
'require' => false
])
->addRule('format', [
'type' => self::TYPE_STRING,
'description' => 'String format.',
'default' => \json_encode(['name'=>APP_DATABASE_ATTRIBUTE_IP]),
'example' => \json_encode(['name'=>APP_DATABASE_ATTRIBUTE_IP]),
'default' => APP_DATABASE_ATTRIBUTE_IP,
'example' => APP_DATABASE_ATTRIBUTE_IP,
'array' => false,
'require' => true,
])

View file

@ -10,6 +10,37 @@ class AttributeInteger extends Attribute
public function __construct()
{
$this
->addRule('key', [
'type' => self::TYPE_STRING,
'description' => 'Attribute Key.',
'default' => '',
'example' => 'fullName',
])
->addRule('type', [
'type' => self::TYPE_STRING,
'description' => 'Attribute type.',
'default' => '',
'example' => 'string',
])
->addRule('status', [
'type' => self::TYPE_STRING,
'description' => 'Attribute status. Possible values: `available`, `processing`, `deleting`, or `failed`',
'default' => '',
'example' => 'string',
])
->addRule('required', [
'type' => self::TYPE_BOOLEAN,
'description' => 'Is attribute required?',
'default' => false,
'example' => true,
])
->addRule('array', [
'type' => self::TYPE_BOOLEAN,
'description' => 'Is attribute an array?',
'default' => false,
'example' => false,
'require' => false
])
->addRule('format', [
'type' => self::TYPE_STRING,
'description' => 'Integer format.',

View file

@ -10,6 +10,37 @@ class AttributeString extends Attribute
public function __construct()
{
$this
->addRule('key', [
'type' => self::TYPE_STRING,
'description' => 'Attribute Key.',
'default' => '',
'example' => 'fullName',
])
->addRule('type', [
'type' => self::TYPE_STRING,
'description' => 'Attribute type.',
'default' => '',
'example' => 'string',
])
->addRule('status', [
'type' => self::TYPE_STRING,
'description' => 'Attribute status. Possible values: `available`, `processing`, `deleting`, or `failed`',
'default' => '',
'example' => 'string',
])
->addRule('required', [
'type' => self::TYPE_BOOLEAN,
'description' => 'Is attribute required?',
'default' => false,
'example' => true,
])
->addRule('array', [
'type' => self::TYPE_BOOLEAN,
'description' => 'Is attribute an array?',
'default' => false,
'example' => false,
'require' => false
])
->addRule('size', [
'type' => self::TYPE_STRING,
'description' => 'Attribute size.',

View file

@ -10,11 +10,42 @@ class AttributeURL extends AttributeString
public function __construct()
{
$this
->addRule('key', [
'type' => self::TYPE_STRING,
'description' => 'Attribute Key.',
'default' => '',
'example' => 'fullName',
])
->addRule('type', [
'type' => self::TYPE_STRING,
'description' => 'Attribute type.',
'default' => '',
'example' => 'string',
])
->addRule('status', [
'type' => self::TYPE_STRING,
'description' => 'Attribute status. Possible values: `available`, `processing`, `deleting`, or `failed`',
'default' => '',
'example' => 'string',
])
->addRule('required', [
'type' => self::TYPE_BOOLEAN,
'description' => 'Is attribute required?',
'default' => false,
'example' => true,
])
->addRule('array', [
'type' => self::TYPE_BOOLEAN,
'description' => 'Is attribute an array?',
'default' => false,
'example' => false,
'require' => false
])
->addRule('format', [
'type' => self::TYPE_STRING,
'description' => 'String format.',
'default' => \json_encode(['name'=>APP_DATABASE_ATTRIBUTE_URL]),
'example' => \json_encode(['name'=>APP_DATABASE_ATTRIBUTE_URL]),
'default' => APP_DATABASE_ATTRIBUTE_URL,
'example' => APP_DATABASE_ATTRIBUTE_URL,
'array' => false,
'required' => true,
])