#### Category : laravel-validation

{"message":"The given data was invalid.","errors":{"category_image":["The category image must be an image.","The category image must be a file of type: jpeg, png, jpg, gif, svg.","The category image may not be greater than 2048 characters."]}} this message shows every time even when I upload .jpg/.png/.jpeg file my validation code: $request->validate([ ‘category_name’ =>’required|min:3|max:20|unique:categories’, ‘publication_status’=>’required’, ‘category_image’ =>’required|image|mimes:jpeg,png,jpg,gif,svg|max:2048′, ]); my .. Read more I have a page with multiple forms on it but I need to validate a specific submitted form. In my view I have this for each input of the forms <div class="form-group"> <label for="name">{{ __(‘Name’)}}</label> <input class="form-control {{$errors->has(‘name’) ? ‘is-invalid’ : ” }}" type="text" name="name" id="name" value="{{ old(‘name’, ”) }}"> @if($errors->storecomment->any()) <div class="invalid-feedback"> @foreach($errors->storecomment->all() ..

there I’m facing an issue with the validation, Input arrays should include at least one value for example when I submit a form I get the following inputs array:26 [ "_token" => "GMPKHos9nnC6zw6UGN4nFKVEGd5PoEpDe9lEPETw" "Customer" => "1" "Text_From_Date" => "07 Jun 2021" "From_Date" => "2021-06-07" "Text_Due_Date" => "16 Jun 2021" "Due_Date" => "2021-06-16" "Invoice_Id" => "INV-1" ..

I am trying to update the data and to do this I am using a method patch on my form. Update Validation Request use IlluminateValidationRule; ‘question’ => [ ‘required’, ‘string’, Rule::unique(‘faqs_questions’,’question’), ‘max:30’, ], If there are no changes in my question it gives me an error: The question has already been taken. dd($this->toArray()) on validation .. Read more I have a database table with the following columns blockID(primary key) , blockName, createdBy, delete(boolean), I am using Laravel 8.x and when the user adds a new block and clicks the submit button, I am validating the name should be unique if the blockName is unique the blockName is stored in the database with delete .. Read more I have a database table with the following columns blockID(primary key) , blockName, createdBy, delete(boolean), I am using Laravel 8.x and when the user adds a new block and clicks the submit button, I am validating the name should be unique if the blockName is unique the blockName is stored in the database with delete .. Read more I got this data from request: { "type": "custom", "start_week": "2020-W19" } And my validation rules are: return [ ‘type’ => ‘required|in:standard,custom’, ‘start_week’ => ‘required|date_format:Y-WW’, ]; Which gives me this result: "errors": { "start_week": [ "The start week does not match the format Y-WW." ] } I used this RegEx format before for validating week .. Read more I want to ask, how can we validate dates from Excel file. I have encountered some weird test cases below. Firstly, I have inputted 5/13/2021 in my excel file, but when I dump in, it doesn’t display same, instead it displays 44329. But fortunately I could able to display to 5/13/2021 using the following codes: .. Read more I have an array of data for example in which they have the same id. [ { id: 222, name: ‘Fff’, } { id: 223, name: ‘Ssss’, }, { id: 222, name: Wwww’, } ] From the data above, the expected behavior is, it should fail because they have the same id. Is there a .. Read more I have problem to validate my image. Its ok on another project but in new project Laravel 8 always fail. View: <label class="btn btn-primary" for="img" style="margin-top: 25px">upload image</label> <input type="file" id="img" name="avatar" accept="image/*" hidden/> Controller:$validated = $request->validate([ ‘avatar’ => ‘image|mimes:jpeg,png,jpg,gif,svg|max:2048’, ]); Error: The avatar must be an image. The avatar must be a file .. Read more table ‘angkatan’ I have table named ‘angkatan’ which has id, id_angkatan, nama_angkatan, and status. status column is enum contain ‘aktif’ and ‘tidak aktif’. i want to give rules for this table in laravel with validaition where this table only allowed to have maximum 4 and minimum 1 of status ‘aktif’. no rules for how many .. Read more I need to validate a string must contains a specific word in the controller. Something Like this ("%name%" is necessary):$request->validate([ ‘pattern’ => [‘required’, ‘must_contains:%name%’], ]); Sourc..

I want to give marks for each student for multiple subjects in different grades (10th,11th,12th) now i pick each student id and I can store marks for each student but i want to avoid duplicate entry for each grade and subjects. example if I give 50 marks in 10th grade for math subject, again if ..

I am trying to test validation on a Laravel page public function user_can_create_event_page() { $user = User::factory()->create();$event = Event::factory()->make()->toArray(); $response =$this->actingAs($user)->post(‘/events’,$event); $response->assertStatus(302);$this->assertNotNull(Event::where(‘name’, $event[‘name’])->first()); } public function user_receives_error_422_if_name_is_not_provided() {$user = User::factory()->create(); $event = Event::factory()->state([‘name’ => ”])->make()->toArray();$response = $this->actingAs($user)->post(‘/events’, $event);$response->assertStatus(422); } and in my validation class EventStoreRequest extends FormRequest { ..

I’m working on an endpoint that has data that is very dependant on each other to determine if it is valid. The data coming in will look something like this: { job: 123 activity: 345 date: 2021-01-01 } There are some checks I will need to do on individual fields, and that all makes sense ..

I want to change message from ValidYouTubeVideo (to translate it in Polish). $this->validateOnly($field, [ (…) ‘youtubeId’ => [‘unique:songs,youtubeId’, new ValidYoutubeVideo], ]); I saw something like that: ‘body.required’ => ‘A message is required’, but unfortunately I don’t know how can I use it. The best option will be __(), but this validation is in a vendor… ..

I have an array of inputs which I need to check for «distinct» statement. If validation fails I have to output error message like: «Property Size has duplicates». If I just put int index in message – it works alright: ‘propertyNames.*.distinct’ => ‘Parameter «’.$this->propertyNames[0].’» has duplicates’ But how to put some key variable in$this->propertyNames[] ..

I have Laravel/Vue application and I’m submiting form with file and some other data using axios. this.loading = true; this.errors = {}; let formData = new FormData(); formData.append(‘type’, this.type); formData.append(‘file’, this.file); formData.append(‘date’, this.date); axios.post(/file-upload, formData, { headers: { ‘Content-Type’: ‘multipart/form-data’ } }) .then((response) => { if (response.status === 200) { this.loading = false; // Success.. ..

I have already asked question about Laravel 5.7 validation, however it still does not work quite right. the validation is not executed at all when sending the content. public function update(Request $request, Player$player) { if(Auth::check()){ $playerUpdate = Player::where(‘id’,$player->id) ->update([ ‘first_name’ => $request->input(‘fist_name’), ‘last_name’ =>$request->input(‘last_name’) ]); if($playerUpdate){ return redirect()->route(‘players.show’, [‘player’=>$player->id]) ->with(‘success’ , ..

My function works by itself but the validation is not executed. Does anyone know what I forgot to add? This is a snippet of my code: namespace AppHttpControllers; use AppPlayer; use AppTournament; use IlluminateHttpRequest; use IlluminateSupportFacadesDB; use IlluminateSupportFacadesAuth; public function store(Request $request) {$request->validate([ ‘first_name’ => ‘alpha|min:2|max:30’, ]); if(Auth::check()){ $foo = Foo::create([ ‘first_name’ =>$request->input(‘fist_name’), ..

I have validation in Laravel application, but I can’t seem to make it work. I am making validation on Supplier model not request. public function requestOpening(Supplier $supplier) {$validator = Validator::make($supplier->toArray(),$this->fullValidationRules()); if ($validator->fails()) { return redirect("open-new/supplier/{$supplier->id}") ->withErrors($validator); } // … } I want hfm_code to be required only when is_hfm == 1. I tried .. Read more I am trying to apply the suggestions provided in this question How to validate array in Laravel? So my validation is ‘topics’ => ‘required|array’ Topics are required This works well especially if topics is an array greater than 1 unfortunately is I pass [] an empty array the validation fails How can I validate that .. Read more i´m traying to create in my laravel 8 two files CreateUserRequest and updateUserRequest for use one validation personaliced. In my function rules i have i´m trayin to call variable of my model$createRules but when i send my form, this don´t send, don´t show messages, error… Nothing. attach my actual code from CreateUserRequest my model ..
I’m trying to upload .docx file: enter image description here My validation rules: return [ ‘first_name’ => [‘required’, ‘latin_nameable’, ‘min:2’, ‘max:20’], ‘last_name’ => [‘required’, ‘latin_nameable’, ‘min:2’, ‘max:20′], ’email’ => [‘required’, ’email’], ‘location’ => [‘required’, Rule::exists(‘city’, ‘city_id’)->where(static function (Builder $query) {$query->where(‘vacancy’, 1); })], ‘skype’ => [‘required_without_all:phone’, ‘min:2’, ‘regex:/^[0-9A-Za-z.-_:]+\$/’], ‘phone’ => [‘required_without_all:skype’, ‘phone:AUTO’], ‘cv’ => ‘mimes:docx,doc’, ..