From 468b2a0b7a2c63846d8c68e369b35ee5830a97b0 Mon Sep 17 00:00:00 2001 From: James Brooks Date: Wed, 19 Oct 2016 12:29:35 +0100 Subject: [PATCH] Fix command validation rules --- .../Component/AddComponentCommand.php | 12 +++++----- .../Component/UpdateComponentCommand.php | 14 ++++++------ .../AddComponentGroupCommand.php | 6 ++--- .../UpdateComponentGroupCommand.php | 8 +++---- .../Incident/ReportIncidentCommand.php | 16 +++++++------- .../Incident/ReportMaintenanceCommand.php | 6 ++--- .../Incident/UpdateIncidentCommand.php | 18 +++++++-------- .../UpdateIncidentUpdateCommand.php | 6 ++--- app/Bus/Commands/Metric/AddMetricCommand.php | 18 +++++++-------- .../Commands/Metric/AddMetricPointCommand.php | 4 ++-- .../Commands/Metric/UpdateMetricCommand.php | 22 +++++++++---------- .../Metric/UpdateMetricPointCommand.php | 4 ++-- app/Bus/Commands/User/AddUserCommand.php | 4 ++-- app/Bus/Commands/User/SignupUserCommand.php | 4 ++-- 14 files changed, 70 insertions(+), 72 deletions(-) diff --git a/app/Bus/Commands/Component/AddComponentCommand.php b/app/Bus/Commands/Component/AddComponentCommand.php index a50e725d..f5d94e3f 100644 --- a/app/Bus/Commands/Component/AddComponentCommand.php +++ b/app/Bus/Commands/Component/AddComponentCommand.php @@ -69,12 +69,12 @@ final class AddComponentCommand */ public $rules = [ 'name' => 'required|string', - 'description' => 'string', - 'status' => 'int|min:1|max:4', - 'link' => 'url', - 'order' => 'int', - 'group_id' => 'int', - 'enabled' => 'bool', + 'description' => 'required|string', + 'status' => 'required|int|min:1|max:4', + 'link' => 'nullable|url', + 'order' => 'nullable|int', + 'group_id' => 'nullable|int', + 'enabled' => 'nullable|bool', ]; /** diff --git a/app/Bus/Commands/Component/UpdateComponentCommand.php b/app/Bus/Commands/Component/UpdateComponentCommand.php index 17c5d12c..ac5bde0a 100644 --- a/app/Bus/Commands/Component/UpdateComponentCommand.php +++ b/app/Bus/Commands/Component/UpdateComponentCommand.php @@ -77,13 +77,13 @@ final class UpdateComponentCommand * @var string[] */ public $rules = [ - 'name' => 'string', - 'description' => 'string', - 'status' => 'int|min:1|max:4', - 'link' => 'url', - 'order' => 'int', - 'group_id' => 'int', - 'enabled' => 'bool', + 'name' => 'nullable|string', + 'description' => 'nullable|string', + 'status' => 'nullable|int|min:1|max:4', + 'link' => 'nullable|url', + 'order' => 'nullable|int', + 'group_id' => 'nullable|int', + 'enabled' => 'nullable|bool', ]; /** diff --git a/app/Bus/Commands/ComponentGroup/AddComponentGroupCommand.php b/app/Bus/Commands/ComponentGroup/AddComponentGroupCommand.php index 2982e495..601370a0 100644 --- a/app/Bus/Commands/ComponentGroup/AddComponentGroupCommand.php +++ b/app/Bus/Commands/ComponentGroup/AddComponentGroupCommand.php @@ -53,9 +53,9 @@ final class AddComponentGroupCommand */ public $rules = [ 'name' => 'required|string', - 'order' => 'int', - 'collapsed' => 'int|between:0,3', - 'visible' => 'bool', + 'order' => 'required|int', + 'collapsed' => 'required|int|between:0,3', + 'visible' => 'required|bool', ]; /** diff --git a/app/Bus/Commands/ComponentGroup/UpdateComponentGroupCommand.php b/app/Bus/Commands/ComponentGroup/UpdateComponentGroupCommand.php index 9f1dbd96..2565e2cd 100644 --- a/app/Bus/Commands/ComponentGroup/UpdateComponentGroupCommand.php +++ b/app/Bus/Commands/ComponentGroup/UpdateComponentGroupCommand.php @@ -61,10 +61,10 @@ final class UpdateComponentGroupCommand * @var string[] */ public $rules = [ - 'name' => 'string', - 'order' => 'int', - 'collapsed' => 'int|between:0,3', - 'visible' => 'bool', + 'name' => 'nullable|string', + 'order' => 'nullable|int', + 'collapsed' => 'nullable|int|between:0,3', + 'visible' => 'nullable|bool', ]; /** diff --git a/app/Bus/Commands/Incident/ReportIncidentCommand.php b/app/Bus/Commands/Incident/ReportIncidentCommand.php index bc42298b..97ce4efb 100644 --- a/app/Bus/Commands/Incident/ReportIncidentCommand.php +++ b/app/Bus/Commands/Incident/ReportIncidentCommand.php @@ -104,14 +104,14 @@ final class ReportIncidentCommand public $rules = [ 'name' => 'required|string', 'status' => 'required|int|min:0|max:4', - 'message' => 'string', - 'visible' => 'bool', - 'component_id' => 'int|required_with:component_status', - 'component_status' => 'int|min:1|max:4|required_with:component_id', - 'notify' => 'bool', - 'stickied' => 'bool', - 'incident_date' => 'string', - 'template' => 'string', + 'message' => 'required|string', + 'visible' => 'nullable|bool', + 'component_id' => 'nullable|required_with:component_status|int', + 'component_status' => 'nullable|required_with:component_id|int|min:1|max:4', + 'notify' => 'nullable|bool', + 'stickied' => 'required|bool', + 'incident_date' => 'nullable|string', + 'template' => 'nullable|string', ]; /** diff --git a/app/Bus/Commands/Incident/ReportMaintenanceCommand.php b/app/Bus/Commands/Incident/ReportMaintenanceCommand.php index 3b44aa10..396f88b7 100644 --- a/app/Bus/Commands/Incident/ReportMaintenanceCommand.php +++ b/app/Bus/Commands/Incident/ReportMaintenanceCommand.php @@ -48,9 +48,9 @@ final class ReportMaintenanceCommand */ public $rules = [ 'name' => 'required|string', - 'message' => 'string', - 'notify' => 'bool', - 'timestamp' => 'string', + 'message' => 'required|string', + 'notify' => 'nullable|bool', + 'timestamp' => 'required|string', ]; /** diff --git a/app/Bus/Commands/Incident/UpdateIncidentCommand.php b/app/Bus/Commands/Incident/UpdateIncidentCommand.php index 3dcd4757..42ca40c8 100644 --- a/app/Bus/Commands/Incident/UpdateIncidentCommand.php +++ b/app/Bus/Commands/Incident/UpdateIncidentCommand.php @@ -105,15 +105,15 @@ final class UpdateIncidentCommand * @var string[] */ public $rules = [ - 'name' => 'string', - 'status' => 'int|min:0|max:4', - 'message' => 'string', - 'visible' => 'bool', - 'component_id' => 'int', - 'component_status' => 'int|min:1|max:4|required_with:component_id', - 'notify' => 'bool', - 'stickied' => 'bool', - 'template' => 'string', + 'name' => 'nullable|string', + 'status' => 'nullable|int|min:0|max:4', + 'message' => 'nullable|string', + 'visible' => 'nullable|bool', + 'component_id' => 'nullable|int', + 'component_status' => 'nullable|int|min:1|max:4|required_with:component_id', + 'notify' => 'nullable|bool', + 'stickied' => 'nullable|bool', + 'template' => 'nullable|string', ]; /** diff --git a/app/Bus/Commands/IncidentUpdate/UpdateIncidentUpdateCommand.php b/app/Bus/Commands/IncidentUpdate/UpdateIncidentUpdateCommand.php index 55370e2a..12d363ad 100644 --- a/app/Bus/Commands/IncidentUpdate/UpdateIncidentUpdateCommand.php +++ b/app/Bus/Commands/IncidentUpdate/UpdateIncidentUpdateCommand.php @@ -55,10 +55,8 @@ final class UpdateIncidentUpdateCommand * @var string[] */ public $rules = [ - 'update' => 'required', - 'status' => 'int|min:1|max:4', - 'message' => 'string', - 'user' => 'required', + 'status' => 'nullable|int|min:1|max:4', + 'message' => 'nullable|string', ]; /** diff --git a/app/Bus/Commands/Metric/AddMetricCommand.php b/app/Bus/Commands/Metric/AddMetricCommand.php index d1dd2546..04ac77a9 100644 --- a/app/Bus/Commands/Metric/AddMetricCommand.php +++ b/app/Bus/Commands/Metric/AddMetricCommand.php @@ -91,15 +91,15 @@ final class AddMetricCommand public $rules = [ 'name' => 'required|string', 'suffix' => 'required|string', - 'description' => 'string', - 'display_chart' => 'bool', - 'default_value' => 'int', - 'calc_type' => 'int', - 'display_chart' => 'int', - 'places' => 'int|between:0,4', - 'default_view' => 'int|between:0,3', - 'threshold' => 'numeric|between:0,10', - 'order' => 'int', + 'description' => 'nullable|string', + 'display_chart' => 'nullable|bool', + 'default_value' => 'required|int', + 'calc_type' => 'required|int', + 'display_chart' => 'nullable|int', + 'places' => 'nullable|int|between:0,4', + 'default_view' => 'required|int|between:0,3', + 'threshold' => 'nullable|numeric|between:0,10', + 'order' => 'nullable|int', ]; /** diff --git a/app/Bus/Commands/Metric/AddMetricPointCommand.php b/app/Bus/Commands/Metric/AddMetricPointCommand.php index ae339585..74c50b3d 100644 --- a/app/Bus/Commands/Metric/AddMetricPointCommand.php +++ b/app/Bus/Commands/Metric/AddMetricPointCommand.php @@ -42,8 +42,8 @@ final class AddMetricPointCommand * @var string[] */ public $rules = [ - 'value' => 'numeric', - 'created_at' => 'string', + 'value' => 'required|numeric', + 'created_at' => 'required|string', ]; /** diff --git a/app/Bus/Commands/Metric/UpdateMetricCommand.php b/app/Bus/Commands/Metric/UpdateMetricCommand.php index 1bf6cd26..5eb71039 100644 --- a/app/Bus/Commands/Metric/UpdateMetricCommand.php +++ b/app/Bus/Commands/Metric/UpdateMetricCommand.php @@ -98,17 +98,17 @@ final class UpdateMetricCommand * @var string[] */ public $rules = [ - 'name' => 'string', - 'suffix' => 'string', - 'description' => 'string', - 'display_chart' => 'bool', - 'default_value' => 'numeric', - 'calc_type' => 'int|in:0,1', - 'display_chart' => 'int', - 'places' => 'numeric|between:0,4', - 'default_view' => 'numeric|between:0,4', - 'threshold' => 'numeric|between:0,10', - 'order' => 'int', + 'name' => 'nullable|string', + 'suffix' => 'nullable|string', + 'description' => 'nullable|string', + 'display_chart' => 'nullable|bool', + 'default_value' => 'nullable|numeric', + 'calc_type' => 'nullable|int|in:0,1', + 'display_chart' => 'nullable|int', + 'places' => 'nullable|numeric|between:0,4', + 'default_view' => 'nullable|numeric|between:0,4', + 'threshold' => 'nullable|numeric|between:0,10', + 'order' => 'nullable|int', ]; /** diff --git a/app/Bus/Commands/Metric/UpdateMetricPointCommand.php b/app/Bus/Commands/Metric/UpdateMetricPointCommand.php index 34bff772..0d976df9 100644 --- a/app/Bus/Commands/Metric/UpdateMetricPointCommand.php +++ b/app/Bus/Commands/Metric/UpdateMetricPointCommand.php @@ -55,8 +55,8 @@ final class UpdateMetricPointCommand * @var string[] */ public $rules = [ - 'value' => 'numeric', - 'created_at' => 'string', + 'value' => 'nullable|numeric', + 'created_at' => 'nullable|string', ]; /** diff --git a/app/Bus/Commands/User/AddUserCommand.php b/app/Bus/Commands/User/AddUserCommand.php index a99ed99f..ef9ecdd6 100644 --- a/app/Bus/Commands/User/AddUserCommand.php +++ b/app/Bus/Commands/User/AddUserCommand.php @@ -53,8 +53,8 @@ final class AddUserCommand */ public $rules = [ 'username' => 'required|string', - 'password' => 'string', - 'level' => 'int', + 'password' => 'required|string', + 'level' => 'required|int', ]; /** diff --git a/app/Bus/Commands/User/SignupUserCommand.php b/app/Bus/Commands/User/SignupUserCommand.php index 7cbf782c..cfba31f5 100644 --- a/app/Bus/Commands/User/SignupUserCommand.php +++ b/app/Bus/Commands/User/SignupUserCommand.php @@ -48,9 +48,9 @@ final class SignupUserCommand */ public $rules = [ 'username' => 'required|string', - 'password' => 'string', + 'password' => 'required|string', 'email' => 'required|string|email', - 'level' => 'int', + 'level' => 'required|int', ]; /**