A free open source IT asset/license management system
new validation rule
spencerrlongg38de69b3da88
diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.phpindex bce5354b72..e42c82841e 100644--- a/app/Http/Controllers/Api/AssetsController.php+++ b/app/Http/Controllers/Api/AssetsController.php@@ -582,11 +582,6 @@ class AssetsController extends Controller// Set the field value based on what was sent in the request$field_val = $request->input($field->db_column, null);- //reduce "array to string conversion" exceptions - ideally we'd handle this in a form request, but this works for now- if(is_array($field_val)) {- return response()->json(Helper::formatStandardApiResponse('error', null, 'This custom field can not be an array', 200));- }-// If input value is null, use custom field's default valueif ($field_val == null) {\Log::debug('Field value for '.$field->db_column.' is null');diff --git a/app/Models/CustomFieldset.php b/app/Models/CustomFieldset.phpindex a2698d818c..a62f96d631 100644--- a/app/Models/CustomFieldset.php+++ b/app/Models/CustomFieldset.php@@ -92,6 +92,8 @@ class CustomFieldset extends Modelarray_push($rule, $field->attributes['format']);$rules[$field->db_column_name()] = $rule;+ //add not_array to rules for all fields+ $rules[$field->db_column_name()][] = 'not_array';}return $rules;diff --git a/app/Providers/ValidationServiceProvider.php b/app/Providers/ValidationServiceProvider.phpindex d7a3c03778..70fa64702e 100644--- a/app/Providers/ValidationServiceProvider.php+++ b/app/Providers/ValidationServiceProvider.php@@ -232,6 +232,10 @@ class ValidationServiceProvider extends ServiceProviderreturn true;}});++ Validator::extend('not_array', function ($attribute, $value, $parameters, $validator) {+ return !is_array($value);+ });}/**diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.phpindex df514da6f9..7720fda79d 100644--- a/resources/lang/en/validation.php+++ b/resources/lang/en/validation.php@@ -95,6 +95,7 @@ return ['url' => 'The :attribute format is invalid.','unique_undeleted' => 'The :attribute must be unique.','non_circular' => 'The :attribute must not create a circular reference.',+ 'not_array' => 'The :attribute field can not be an array.','disallow_same_pwd_as_user_fields' => 'Password cannot be the same as the username.','letters' => 'Password must contain at least one letter.','numbers' => 'Password must contain at least one number.',