Category : validation

I want to write custom from validation , but when I’m using custom validation in my store controller it gets me error the error is : InvalidArgumentException: Database connection [vendor] not configured. in file D:clodth_projectcloth_apivendorlaravelframeworksrcIlluminateDatabaseDatabaseManager.php on line 152 my validation class is : class StoreRequest extends FormRequest { /** * Determine if the user is ..

Read more

i’ new to laravel here i’m create registration API, i set private function for validation but not show validation. that is my validation function `private function validateInfo($request, $toValidate) { $validator = Validator::make($request->all(), $toValidate); if ($validator->fails()) { $errors = $validator->errors()->toArray(); $values = array_values($errors); $arr = []; foreach ($values as $errorlst) array_push($arr, $errorlst[0]); $error = implode(‘,’, $arr); ..

Read more

I need help to set a minimum age for the user to be over 18 years. This is the user’s controller $request->validate([ ‘first_name’ => ‘required|max:255’, ‘last_name’ => ‘required|max:255’, ‘status’ => ‘required|max:50’, ‘phone’ => ‘required’,’unique:users’,’min:10′,’numeric’, ‘date_of_birth’ =>’required|date’, ‘address’ => ‘required|max:255’, ‘country’ => ‘required’, ‘role_id’ => ‘required|max:11′, ’email’ =>[ ‘required’, ’email’, ‘max:255’, Rule::unique(‘users’)->ignore($row->id) ], profile blade <div ..

Read more

In profile.blade, while updating the inputs in the profile getting Error The phone has already been taken. Controller: public function profileUpdate(Request $request) { $user = Auth::user(); $messages = [ ‘user_name.required’ => __(‘The User name field is required.’), ‘last_name.required’ => __(‘The Last Name field is required.’), ‘first_name.required’ => __(‘The First Name field is required.’), ‘phone.required’ => ..

Read more

I want to set require validation for array of objects in laravel and used following rule: [ ‘translations.*.languageId’ => [‘required’, ‘numeric’, Rule::in(Language::all()->pluck(‘id’))], ‘translations.*.data.title’ => ‘required|string’, ] but there is problem when i send request without translations key the validate function does not throw require error for translation key. so i add translations key separately too. ..

Read more

I have been using Laravel for a couple weeks now and I love the framework. However, with models is there any actual robust system? Creating models, like the user model, just seems to be string arrays of what you do and do not want modified in queries. The place I see validation of the models ..

Read more

I’m building custom avatar functionality for my project. Users can select an image to upload. I made validation as follows: ‘avatar’ => ‘nullable|max:10000|image|mimes:png,jpeg,jpg’ It works for real file extensions like .docx and .xlsx. However, when i upload fake file extensions like .pnh and .yukelele, my validation weirdly succeeds. Does anyone have a fix? Sourc..

Read more

I would like to create a validation rule which checks if the combination of two values is unique. There is a field for the street (id) and the house number. Both fields are required. Further, no new entry should be created if a certain combination of street and house number already exists. How can I ..

Read more

{ "name" : "parent_node", "children: [ { "name" : "child-1", "children: [ { "name" : "subchild-1", //unlimited childrens } ] } ] } —————————————— $rules = ([ ‘name’ => ‘required|string’, ‘children.*.name’ => ‘required|string’ ]); I want to check validation dynamically on dynamic nested array Instead of using ‘children.*.name Validation should check nested array itself because ..

Read more

I’m sending have an array of JSON objects that I’m POSTing to the DB with other data: { "emotions":[ { "id":1, "intensity":67, "new_intensity":67 }, { "id":2, "intensity":67, "new_intensity":67 }, { "id":3, "intensity":64, "new_intensity":64 }, { "id":4, "intensity":64, "new_intensity":64 }, { "id":5, "intensity":64, "new_intensity":64 } ], "situation":"An event", } What I want to do is validate ..

Read more

I’m working on laravel Project i’m using custom messages when laravel validation fails when i try to store data. All messages working fine only password confirmed same error not showing any message Method: public function store(Request $request) { $validatedData = $request->validate( [ ‘name’ => ‘required’, ‘username’ => ‘required|unique:users’, ‘age’ => ‘required’, ‘sex’ => ‘required’, ‘organization_id’ ..

Read more

I would need some help understanding what I am doing wrong. I have really basic ‘required’ fields defined in a PostUpdateRequest rules method. Then, my update method in PostController: public function update(PostUpdateRequest $request, Post $post) { $post->update($request->validated()); $post->tags()->sync(request(‘tags’)); return redirect() … } When I use the method without validation, it works: public function update(Request $request, ..

Read more

I would like to validate multiple upload image in laravel using ajax, I use dynamic add/remove upload file. Maybe the problem in my validation controller, because json doesn’t response this is my controller : $rules =[ ‘img_thumbnail.*.file’ => [‘image’,’mimes:jpeg,png’,’max:5000′], ]; $message = [ ‘img_thumbnail.*file.required’ => ‘Image must fill’, ‘img_thumbnail.*file.image’ => ‘File Should Image’, ‘img_thumbnail.*file.mimes’ => ..

Read more

I have the following validation logic, but it does not work properly: public function getFeedback(Request $request) { $validator = Validator::make($request->all(), [ ‘id.*’ => ‘integer’, ‘job_id.*’ => ‘integer’, ‘quality_cycle_id.*’ => ‘integer’, ‘rating.*’ => ‘ineteger’, ]); if($validator->fails()) { return back()->withInput()->withErrors(json($validator->errors())); } } Sourc..

Read more