From 33b1ab3658d2e6fcaa2083fede60f7041fce8b06 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 10 May 2022 16:19:06 -0700 Subject: [PATCH] prevents values for assets being negative through validation --- app/Models/Asset.php | 2 +- resources/lang/en/validation.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Models/Asset.php b/app/Models/Asset.php index ac373b2ad4..3466cbffe7 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -111,7 +111,7 @@ class Asset extends Depreciable 'asset_tag' => 'required|min:1|max:255|unique_undeleted', 'status' => 'integer', 'serial' => 'unique_serial|nullable', - 'purchase_cost' => 'numeric|nullable', + 'purchase_cost' => 'numeric|nullable|gte:0', 'next_audit_date' => 'date|nullable', 'last_audit_date' => 'date|nullable', 'supplier_id' => 'exists:suppliers,id|nullable', diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index 72b465f211..5f097b717c 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -91,6 +91,10 @@ return [ 'url' => 'The :attribute format is invalid.', 'unique_undeleted' => 'The :attribute must be unique.', 'non_circular' => 'The :attribute must not create a circular reference.', + 'gte' => [ + 'numeric' => 'Value cannot be negative' + ], + /* |--------------------------------------------------------------------------