Skip to content

A free open source IT asset/license management system

Fixes #18377 - make min value for names consistent

snipe5e9e0b70db0a
diff --git a/app/Models/Accessory.php b/app/Models/Accessory.php
index 8edfac2115..df0f916ffb 100755
--- a/app/Models/Accessory.php
+++ b/app/Models/Accessory.php
@@ -61,7 +61,7 @@ class Accessory extends SnipeModel
* Accessory validation rules
*/
public $rules = [
- 'name' => 'required|min:3|max:255',
+ 'name' => 'required|max:255',
'qty' => 'required|integer|min:1',
'category_id' => 'required|integer|exists:categories,id',
'company_id' => 'integer|nullable',
diff --git a/app/Models/Company.php b/app/Models/Company.php
index 4cd8c8e724..66a1719ede 100644
--- a/app/Models/Company.php
+++ b/app/Models/Company.php
@@ -27,10 +27,10 @@ final class Company extends SnipeModel
// Declare the rules for the model validation
protected $rules = [
- 'name' => 'required|min:1|max:255|unique:companies,name',
+ 'name' => 'required|max:255|unique:companies,name',
'fax' => 'min:7|max:35|nullable',
'phone' => 'min:7|max:35|nullable',
- 'email' => 'email|max:150|nullable',
+ 'email' => 'email|max:150|nullable',
];
protected $presenter = \App\Presenters\CompanyPresenter::class;
diff --git a/app/Models/Component.php b/app/Models/Component.php
index 445a2cc530..1a530b8883 100644
--- a/app/Models/Component.php
+++ b/app/Models/Component.php
@@ -36,7 +36,7 @@ class Component extends SnipeModel
* Category validation rules
*/
public $rules = [
- 'name' => 'required|min:3|max:191',
+ 'name' => 'required|max:191',
'qty' => 'required|integer|min:1',
'category_id' => 'required|integer|exists:categories,id',
'supplier_id' => 'nullable|integer|exists:suppliers,id',
diff --git a/app/Models/Consumable.php b/app/Models/Consumable.php
index 78c908177d..a48636546f 100644
--- a/app/Models/Consumable.php
+++ b/app/Models/Consumable.php
@@ -42,7 +42,7 @@ class Consumable extends SnipeModel
* Category validation rules
*/
public $rules = [
- 'name' => 'required|min:3|max:255',
+ 'name' => 'required|max:255',
'qty' => 'required|integer|min:0|max:99999',
'category_id' => 'required|integer',
'company_id' => 'integer|nullable',
diff --git a/app/Models/Depreciation.php b/app/Models/Depreciation.php
index 6e01c6d782..a74ac30e91 100755
--- a/app/Models/Depreciation.php
+++ b/app/Models/Depreciation.php
@@ -15,7 +15,7 @@ class Depreciation extends SnipeModel
use Presentable;
// Declare the rules for the form validation
protected $rules = [
- 'name' => 'required|min:3|max:255|unique:depreciations,name',
+ 'name' => 'required|max:255|unique:depreciations,name',
'months' => 'required|max:3600|integer',
];
diff --git a/app/Models/Group.php b/app/Models/Group.php
index 9f4f2e2e56..dae02d93f5 100755
--- a/app/Models/Group.php
+++ b/app/Models/Group.php
@@ -13,7 +13,7 @@ class Group extends SnipeModel
protected $table = 'permission_groups';
public $rules = [
- 'name' => 'required|min:2|max:255|unique',
+ 'name' => 'required|max:255|unique',
];
protected $fillable = [
diff --git a/app/Models/License.php b/app/Models/License.php
index 3f6bcf1c13..444349a08e 100755
--- a/app/Models/License.php
+++ b/app/Models/License.php
@@ -47,7 +47,7 @@ class License extends Depreciable
];
protected $rules = [
- 'name' => 'required|string|min:3|max:255',
+ 'name' => 'required|string|max:255',
'seats' => 'required|min:1|integer|limit_change:10000', // limit_change is a "pseudo-rule" that translates into 'between', see prepareLimitChangeRule() below
'license_email' => 'email|nullable|max:120',
'license_name' => 'string|nullable|max:100',
diff --git a/app/Models/Location.php b/app/Models/Location.php
index ab2536bd0b..aa53300bdb 100755
--- a/app/Models/Location.php
+++ b/app/Models/Location.php
@@ -26,7 +26,7 @@ class Location extends SnipeModel
protected $table = 'locations';
protected $rules = [
- 'name' => 'required|min:2|max:255|unique_undeleted',
+ 'name' => 'required|max:255|unique_undeleted',
'address' => 'max:191|nullable',
'address2' => 'max:191|nullable',
'city' => 'max:191|nullable',
diff --git a/app/Models/Manufacturer.php b/app/Models/Manufacturer.php
index cc1d2c1753..273aa6aca0 100755
--- a/app/Models/Manufacturer.php
+++ b/app/Models/Manufacturer.php
@@ -21,7 +21,7 @@ class Manufacturer extends SnipeModel
// Declare the rules for the form validation
protected $rules = [
- 'name' => 'required|min:2|max:255|unique:manufacturers,name,NULL,id,deleted_at,NULL',
+ 'name' => 'required|max:255|unique:manufacturers,name,NULL,id,deleted_at,NULL',
'url' => 'nullable|starts_with:http://,https://,afp://,facetime://,file://,irc://',
'support_email' => 'email|nullable',
'support_url' => 'nullable|starts_with:http://,https://,afp://,facetime://,file://,irc://',
diff --git a/app/Models/PredefinedKit.php b/app/Models/PredefinedKit.php
index 2d0c87066e..3b32e27cb7 100644
--- a/app/Models/PredefinedKit.php
+++ b/app/Models/PredefinedKit.php
@@ -25,7 +25,7 @@ class PredefinedKit extends SnipeModel
* Category validation rules
*/
public $rules = [
- 'name' => 'required|min:1|max:255|unique',
+ 'name' => 'required|max:255|unique',
];
use ValidatingTrait;
diff --git a/app/Models/Statuslabel.php b/app/Models/Statuslabel.php
index bd981d867a..049b8d7de1 100755
--- a/app/Models/Statuslabel.php
+++ b/app/Models/Statuslabel.php
@@ -21,7 +21,7 @@ class Statuslabel extends SnipeModel
protected $hidden = ['user_id', 'deleted_at'];
protected $rules = [
- 'name' => 'required|string|unique_undeleted',
+ 'name' => 'required|max:255|string|unique_undeleted',
'notes' => 'string|nullable',
'deployable' => 'required',
'pending' => 'required',
diff --git a/app/Models/Supplier.php b/app/Models/Supplier.php
index 161ced1b59..7880c571d2 100755
--- a/app/Models/Supplier.php
+++ b/app/Models/Supplier.php
@@ -23,7 +23,7 @@ class Supplier extends SnipeModel
protected $table = 'suppliers';
protected $rules = [
- 'name' => 'required|min:1|max:255|unique_undeleted',
+ 'name' => 'required|max:255|unique_undeleted',
'fax' => 'min:7|max:35|nullable',
'phone' => 'min:7|max:35|nullable',
'contact' => 'max:100|nullable',
diff --git a/app/Models/User.php b/app/Models/User.php
index 2c56c43737..406aece1f3 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -105,7 +105,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
*/
protected $rules = [
- 'first_name' => 'required|string|min:1|max:191',
+ 'first_name' => 'required|string|max:191',
'last_name' => 'nullable|string|max:191',
'display_name' => 'nullable|string|max:191',
'username' => 'required|string|min:1|unique_undeleted|max:191',
diff --git a/resources/lang/en-US/general.php b/resources/lang/en-US/general.php
index 771e85a591..e0545d4e2a 100644
--- a/resources/lang/en-US/general.php
+++ b/resources/lang/en-US/general.php
@@ -206,7 +206,7 @@ return [
'manufacturers' => 'Manufacturers',
'markdown' => 'This field allows <a href="https://help.github.com/articles/github-flavored-markdown/">Github flavored markdown</a>.',
'min_amt' => 'Min. QTY',
- 'min_amt_help' => 'Minimum number of items that should be available before an alert gets triggered. Leave Min. QTY blank if you do not want to receive alerts for low inventory.',
+ 'min_amt_help' => 'Minimum number of this item that should be available for checkout before an alert gets triggered. Leave blank if you do not wish to receive alerts for low inventory.',
'model_no' => 'Model No.',
'months' => 'months',
'moreinfo' => 'More Info',
diff --git a/resources/views/consumables/edit.blade.php b/resources/views/consumables/edit.blade.php
index 4ce6de9d78..0d947fdb43 100644
--- a/resources/views/consumables/edit.blade.php
+++ b/resources/views/consumables/edit.blade.php
@@ -15,8 +15,10 @@
@section('inputFields')
@include ('partials.forms.edit.company-select', ['translated_name' => trans('general.company'), 'fieldname' => 'company_id'])
-@include ('partials.forms.edit.name', ['translated_name' => trans('admin/consumables/table.title')])
+@include ('partials.forms.edit.name', ['translated_name' => trans('general.name')])
@include ('partials.forms.edit.category-select', ['translated_name' => trans('general.category'), 'fieldname' => 'category_id', 'required' => 'true', 'category_type' => 'consumable'])
+@include ('partials.forms.edit.quantity')
+@include ('partials.forms.edit.minimum_quantity')
@include ('partials.forms.edit.supplier-select', ['translated_name' => trans('general.supplier'), 'fieldname' => 'supplier_id'])
@include ('partials.forms.edit.manufacturer-select', ['translated_name' => trans('general.manufacturer'), 'fieldname' => 'manufacturer_id'])
@include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'location_id'])
@@ -25,8 +27,6 @@
@include ('partials.forms.edit.order_number')
@include ('partials.forms.edit.datepicker', ['translated_name' => trans('general.purchase_date'),'fieldname' => 'purchase_date'])
@include ('partials.forms.edit.purchase_cost', [ 'unit_cost' => trans('general.unit_cost')])
-@include ('partials.forms.edit.quantity')
-@include ('partials.forms.edit.minimum_quantity')
@include ('partials.forms.edit.notes')
@include ('partials.forms.edit.image-upload', ['image_path' => app('consumables_upload_path')])
diff --git a/resources/views/partials/forms/edit/minimum_quantity.blade.php b/resources/views/partials/forms/edit/minimum_quantity.blade.php
index 60589a3ebe..9f05ac00ab 100644
--- a/resources/views/partials/forms/edit/minimum_quantity.blade.php
+++ b/resources/views/partials/forms/edit/minimum_quantity.blade.php
@@ -2,17 +2,17 @@
<div class="form-group{{ $errors->has('min_amt') ? ' has-error' : '' }}">
<label for="min_amt" class="col-md-3 control-label">{{ trans('general.min_amt') }}</label>
<div class="col-md-9">
- <div class="col-md-2" style="padding-left:0px">
- <input class="form-control col-md-3" maxlength="5" type="text" name="min_amt" id="min_amt"
+ <div class="col-md-3" style="padding-left:0px">
+ <input class="form-control col-md-3" maxlength="5" type="number" name="min_amt" id="min_amt"
aria-label="min_amt"
+ min="0"
value="{{ old('min_amt', ($item->min_amt ?? '')) }}"
{{ (isset($item) && (Helper::checkIfRequired($item, 'min_amt')) ? ' required' : '') }}/>
</div>
- <div class="col-md-7" style="margin-left: -15px;">
- <x-form-tooltip>
- {{ trans('general.min_amt_help') }}
- </x-form-tooltip>
- </a>
+ <div class="col-md-7" style="margin-left: -15px;">
+ <x-form-tooltip>
+ {{ trans('general.min_amt_help') }}
+ </x-form-tooltip>
</div>
<div class="col-md-12">
{!! $errors->first('min_amt', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
diff --git a/resources/views/partials/forms/edit/quantity.blade.php b/resources/views/partials/forms/edit/quantity.blade.php
index 0ddf6cebae..403e0f5343 100644
--- a/resources/views/partials/forms/edit/quantity.blade.php
+++ b/resources/views/partials/forms/edit/quantity.blade.php
@@ -2,11 +2,11 @@
<!-- QTY -->
<div class="form-group {{ $errors->has('qty') ? ' has-error' : '' }}">
<label for="qty" class="col-md-3 control-label">{{ trans('general.quantity') }}</label>
- <div class="col-md-7">
- <div class="col-md-3" style="padding-left:0px">
- <input class="form-control" maxlength="5" type="text" name="qty" aria-label="qty" id="qty" value="{{ old('qty', $item->qty) }}" {!! (Helper::checkIfRequired($item, 'qty')) ? ' required ' : '' !!}/>
+ <div class="col-md-9">
+ <div class="col-md-3" style="padding-left:0">
+ <input class="form-control" maxlength="5" min="1" type="number" name="qty" aria-label="qty" id="qty" value="{{ old('qty', $item->qty) }}" {!! (Helper::checkIfRequired($item, 'qty')) ? ' required ' : '' !!}/>
</div>
- <div class="col-md-12" style="padding-left:0px">
+ <div class="col-md-12" style="padding-left:0">
{!! $errors->first('qty', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>