From 3c4f254583d8454a70c50f95538b7f61f4c7ba10 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 24 Jan 2023 13:38:53 -0800 Subject: [PATCH] Enforce Y-m-d as date format for date fields Signed-off-by: snipe --- app/Models/Accessory.php | 1 + app/Models/Asset.php | 9 +++++---- app/Models/Component.php | 2 +- app/Models/Consumable.php | 1 + app/Models/License.php | 3 +++ app/Models/User.php | 4 ++-- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/Models/Accessory.php b/app/Models/Accessory.php index 3f2004b047..9569917ab3 100755 --- a/app/Models/Accessory.php +++ b/app/Models/Accessory.php @@ -63,6 +63,7 @@ class Accessory extends SnipeModel 'company_id' => 'integer|nullable', 'min_amt' => 'integer|min:0|nullable', 'purchase_cost' => 'numeric|nullable|gte:0', + 'purchase_date' => 'date_format:Y-m-d|nullable', ]; diff --git a/app/Models/Asset.php b/app/Models/Asset.php index f8e0cab314..75e1f38e45 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -105,16 +105,17 @@ class Asset extends Depreciable 'company_id' => 'integer|nullable', 'warranty_months' => 'numeric|nullable|digits_between:0,240', 'physical' => 'numeric|max:1|nullable', - 'checkout_date' => 'date|max:10|min:10|nullable', - 'checkin_date' => 'date|max:10|min:10|nullable', + 'checkout_date' => 'date_format:Y-m-d|max:10|min:10|nullable', + 'checkin_date' => 'date_format:Y-m-d|max:10|min:10|nullable', 'location_id' => 'exists:locations,id|nullable', 'rtd_location_id' => 'exists:locations,id|nullable', 'asset_tag' => 'required|min:1|max:255|unique_undeleted', 'status' => 'integer', + 'purchase_date' => 'date_format:Y-m-d|nullable', 'serial' => 'unique_serial|nullable', 'purchase_cost' => 'numeric|nullable|gte:0', - 'next_audit_date' => 'date|nullable', - 'last_audit_date' => 'date|nullable', + 'next_audit_date' => 'date_format:Y-m-d|nullable', + 'last_audit_date' => 'date_format:Y-m-d|nullable', 'supplier_id' => 'exists:suppliers,id|nullable', ]; diff --git a/app/Models/Component.php b/app/Models/Component.php index dc353d288c..98230132be 100644 --- a/app/Models/Component.php +++ b/app/Models/Component.php @@ -35,7 +35,7 @@ class Component extends SnipeModel 'category_id' => 'required|integer|exists:categories,id', 'company_id' => 'integer|nullable', 'min_amt' => 'integer|min:0|nullable', - 'purchase_date' => 'date|nullable', + 'purchase_date' => 'date_format:Y-m-d|nullable', 'purchase_cost' => 'numeric|nullable|gte:0', ]; diff --git a/app/Models/Consumable.php b/app/Models/Consumable.php index c04c9b53d5..ea4ac6086b 100644 --- a/app/Models/Consumable.php +++ b/app/Models/Consumable.php @@ -41,6 +41,7 @@ class Consumable extends SnipeModel 'company_id' => 'integer|nullable', 'min_amt' => 'integer|min:0|nullable', 'purchase_cost' => 'numeric|nullable|gte:0', + 'purchase_date' => 'date_format:Y-m-d|nullable', ]; /** diff --git a/app/Models/License.php b/app/Models/License.php index b59387a42e..d3c4d8a1c3 100755 --- a/app/Models/License.php +++ b/app/Models/License.php @@ -50,6 +50,9 @@ class License extends Depreciable 'category_id' => 'required|exists:categories,id', 'company_id' => 'integer|nullable', 'purchase_cost'=> 'numeric|nullable|gte:0', + 'purchase_date' => 'date_format:Y-m-d|nullable', + 'expiration_date' => 'date_format:Y-m-d|nullable', + 'termination_date' => 'date_format:Y-m-d|nullable', ]; /** diff --git a/app/Models/User.php b/app/Models/User.php index 34c0af6b2e..4d430af741 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -98,8 +98,8 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo 'website' => 'url|nullable|max:191', 'manager_id' => 'nullable|exists:users,id|cant_manage_self', 'location_id' => 'exists:locations,id|nullable', - 'start_date' => 'nullable|date', - 'end_date' => 'nullable|date|after_or_equal:start_date', + 'start_date' => 'nullable|date_format:Y-m-d', + 'end_date' => 'nullable|date_format:Y-m-d|after_or_equal:start_date', ]; /**