896 questions
0
votes
3
answers
187
views
Inconsistency in Spatie laravel-data validation
I am encountering 500 error in when I try to initialize Spatie Laravel Data class with null field instead of 422
Here is the class:
namespace App\Data;
use Spatie\LaravelData\Attributes\Validation\...
0
votes
0
answers
37
views
How to make validation of entered text in 1 language? [duplicate]
How can I on laravel 10 site to check that field user_name is only text and in 1 language(ukrainian) ?
FIX_ATTEMPT :
I try to make it simple :
class CheckUkrainianAlphabet
{
public function check(...
2
votes
1
answer
205
views
Log in using your phone number and email address in Breeze laravel 11 [duplicate]
I want to log in using my phone number or email in Laravel 11 with Breeze.
┌──────────────────────────────────────────────┐
│ ...
0
votes
1
answer
92
views
How can I validate form data in a Laravel controller using request validation?
I have to build a user registration form for a web application in Laravel. The form should collect the following data from users:
Name: The user's full name.
Email: The user's email address.
Password: ...
1
vote
1
answer
57
views
Why calling custom rule in livewire app raised error?
In laravel 11 / livewire 3.5 app Icreated a custom rule with command :
php artisan make:rule LocationIsValidRule
and having a file with declaration :
<?php
namespace App\Rules;
use App\Library\...
0
votes
1
answer
95
views
Why unique rule does not work in Livewire validate attribute?
On Laravel / Livewire site item model has unique "title" field and I added unique in validate attribute
class ItemEditor extends Component
{
#[Validate('required|string|min:3|max:255|...
0
votes
1
answer
111
views
Laravel 10 custom validation rule testing
I created a simple custom validation rule via php artisan make:rule, and now I want to write unit tests for it.
How do I test a validation rule to pass or fail?
Since $rule->validate() does not ...
0
votes
2
answers
105
views
weird laravel validation in nested array
I tried some validation rule like: Boolean and Required file with nested array field, but always failing
for example, I tried creating form request like this:
<?php
namespace App\Http\Requests\...
0
votes
1
answer
120
views
PHPUnit and Laravel responds 401 status code it should return 422
I'm studying Laravel 11 and I have my first problem using PHPStorm (I don't know if it's my test or not).
I have this controller:
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\...
0
votes
2
answers
90
views
Validation, required if 2 other fields have specified values
I have validation in Laravel 10 that contains validation for company_description. I want it to be required when two other fields have specified values. I got this code:
'company_description' => [
...
1
vote
2
answers
117
views
Laravel validation distinct only for its siblings array element
We have this validation code:
$data = [
[1, 2, 3],
[3, 4, 5]
];
$validator = \Validator::make([
"bla" => $data,
], [
'bla' => 'required|array',
'bla.*' ...
-1
votes
3
answers
80
views
How to check decimal values from 0 till 100?
On Laravel 11 site I need to check decimal values from 0 till 100(with 2 decimals possible) and I do it with rules :
['required', 'numeric', 'between:0,100'],
OR
required|numeric|min:0.01|max:100
...
1
vote
0
answers
110
views
How to fix Laravel Validation error: 'The field is required'?
Why am I getting this error: The remarks field is required.? Note that the remarks has a value. When I dump the validated request, the remarks exists. The introduction field is same as the remarks but ...
0
votes
3
answers
312
views
Check if an UUID exists in Table A or Table B using Validation Rules (Laravel Validation)?
In my Laravel application, I would like to check wether the value of the field uuid is present in table courses or in table contingents using validation rules. The UUID must be present in one of the ...
0
votes
1
answer
643
views
Laravel - Validate if email already exists in table users
I have a simple Angular 16 login/register form;
when a user registers in my app, register data is sent via http request to my laravel backend, where i handle user registration.
before i create a new ...
1
vote
1
answer
52
views
Laravel email validation issue during user information update
I'm relatively new to Laravel and I've run into a problem. When users edit their information in my system, I want to bypass the email validation. Specifically, they shouldn't receive an error stating ...
1
vote
1
answer
257
views
Efficient way to check for overlapping ranges in a database, Laravel validation
I have a model named ClientDiscountRate, which naturally corresponds to a table.
I am developing a method to allow the creation of a new ClientDiscountRate. However, I am facing a problem: the ...
0
votes
1
answer
538
views
Postgres 'invalid input syntax for type uuid' error interrupts Laravel 11.x validation
I'm encountering an issue in my Laravel application where the validation process stops working due to a "invalid input syntax for type uuid" error from Postgres. This occurs when I try to ...
0
votes
1
answer
160
views
Get the length of an array using closure validation
What I am trying to do is to get the length of an array inside closure Laravel validation.
Here is what I have tried:
'attachment' => 'max:10',
'attachment.*' => 'max:10240|mimes:...
0
votes
1
answer
193
views
Get ID of user being updated inside Form Request to ignore validation when updating same user
When updating a specific user, I want to run unique validation for the 'username' and 'studentNumber' fields, but only for other users and not for the same user being updated because its already owned ...
0
votes
1
answer
64
views
Laravel 10 - always validate field even if the field isn't in the request [duplicate]
I have following segment of the validation:
'places' => [
new CompanyHasPlacesRule,
],
and the validation class:
public function validate(string $attribute, mixed $value, Closure $fail): void
...
0
votes
0
answers
43
views
Laravel, Validator check if two columns exist in same table
i have 3 parameters (br_code,slc_code,slt_code)
im done with validations for br_code and slc_code
to validate slt_code, i have to check if slc_code and slt_code exist on table(sltype) , how do i do it?...
1
vote
1
answer
141
views
Specifying Custom Attribute Values does not work Laravel
I have the following code:
use Illuminate\Support\Facades\Validator;
$rules = array(
'attachment' => 'max:1000|file|mimes:jpeg,png,jpg,gif,svg,pdf',
);
$messages = array(
'attachment....
0
votes
2
answers
93
views
Laravel default validation message not working
The default validation error message in Laravel is not functioning as expected. When using validation, the response displays a generic message like (validation.required) instead of the intended ...
1
vote
2
answers
120
views
Laravel validation not allow to be false all
I am a beginnerwith the Laravel framework. I am struggling to declare validation of request data. I have some checkboxes in the form, and at least one of the checkboxes must be selected to submit to ...
0
votes
0
answers
270
views
how to validate datetime on laravel validator with date_format rule
Datetime input on Form
this my input datetime in form, the format is 30/12/2023 11.52.18
i want to validate that format with laravel validation rule data_format
i was try on laravel validation rule -&...
0
votes
1
answer
513
views
Laravel validation errors if not using Validator facade
I have this code for an API, testing with Postman:
public function register(Request $request)
{
$validated = $request->validate([
'name' => 'required|string',
'email' => '...
0
votes
1
answer
86
views
Laravel validate sync input data with intermediate table values always fails
I'm trying to sync with additional data, like this:
$game->contestants()->sync([3 => ['budget' => 30.5], 7 => ['budget' => 25]])
Which works as expected, but I am trying to validate ...
0
votes
3
answers
2k
views
Laravel 10 - validation rule "string or array"
I need to add validation for a dynamic array whose elements can be strings or subsequent arrays containing strings, but I can't find a way to save this rule.
My current validation:
$data = $...
0
votes
3
answers
529
views
Laravel date validation erroring for string "today"
I'm using laravel validation for a date field like this:
Validator::make($shipment, [
'collection_date' => 'required|date',
...
and I'm sending json with this field:
"...
1
vote
2
answers
2k
views
Validator class in Laravel 10
In my controller I validate fields of my json request. To obey single responsibility, I want to create a custom Validator class and put following code to my validator class.
When I type:
php artisan ...
-1
votes
1
answer
77
views
Laravel Socialite User Creation Validation?
I was trying to implement socialite login register with Laravel. But i failed to validate data with laravel default validation Rule. Like in user table , email should be unique. How can i implement ...
0
votes
0
answers
111
views
Laravel validation message for max size is incorrect
I'm currently facing this issue where I want to use the max key when I upload a file. But then it returns a different message. The max key returns the uploaded message instead of the max message. I ...
0
votes
1
answer
154
views
Validating multiple forms at once
Our app has multiple identical forms on a page. Before submitting the data, I want to validate the inputs of all the forms with a single request from Vue.
I came up with the following frontend portion
...
-1
votes
2
answers
526
views
Admin guard login, The email field is required, Laravel 10
Previously it worked before I edit it for firebase, but for now I want to see local auth first after I edit it for firebase. it can register but not login, it resulted in The email field is required. ...
0
votes
1
answer
95
views
Laravel - Trigger endpoint validation only [duplicate]
I have many endpoints in Laravel that utilise FormRequests for validation. Is there a way to trigger those endpoints' validation only?
The use case for this is that I want to trigger multiple ...
-1
votes
1
answer
382
views
Laravel Validation for Multiple input values
I am working on the Laravel Validation code. In my code, I used the radio button for three options like approve, reject, and return. In the Remarks textbox, validation depends on the Radio button ...
2
votes
0
answers
103
views
How to validate 2 separated string with Validator in laravel 6?
I would like to make a validation for the input string using Laravel 6 with the input condition as below.
userNo = "5031234567" => Len = 10 digits and must start with 503.
I tried to ...
0
votes
0
answers
471
views
Nested Validation in Laravel + Livewire
I am trying to build a dynamic form for a warehouse management portal using Laravel and Livewire. For that form I need validation for all the input values. I have followed the exact format given in ...
0
votes
3
answers
151
views
Laravel date validation if checkbox is selected
I'm trying to build an application in Laravel where I need to take input user's job experience with their start date and end date. There is a use case where the user can be currently working in any ...
0
votes
0
answers
132
views
Laravel check box validation - user must select at least one check box
I have checked out several post with similar question ( for an example ) But did not quite found the answer I am looking for.
I am working on a Laravel multi-step form. and in one of the step the code ...
1
vote
1
answer
1k
views
Laravel validation rules for arrays failed when sending multipart/form-data using Reactjs
I'm trying to make a POST Request to Laravel from Reactjs to insert into the database a product which may have some categories which is an array, also some images.
But it seems that when I send the ...
0
votes
1
answer
522
views
Laravel validation if fails return POST method instead of GET
I access a page of Route::post('search'). From this page, I perform a form submission using a POST method. If the validation fails, I get error The GET method is not supported for this route. ...
0
votes
1
answer
87
views
Laravel Validation on Array Item
I am trying to achieve validation on Pickings Array where the location is unique,
{
"id": 10,
"type": "picking",
"pickings": [
{
"id": ...
0
votes
1
answer
935
views
Laravel 8 remove error message from validator errorMessageBag
I am using laravel 8. I need to validate 3 fields to make 1 phone number. The flow is to combine the 3 fields and then save to database. Validation is triggered when one of the fields is not the ...
0
votes
1
answer
162
views
validation after error continue checking . not stop
I have form request AccountGrantRequest
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class AccountGrantRequest extends FormRequest
{
public function authorize():...
0
votes
2
answers
556
views
Indicate the incorrect key in Laravel's array rule validation error message
I am doing FormRequest validation. I am using the array rule to ensure that only specified keys are allowed in the validated array. For example:
$rules = [
'example' => ['array:something,another']...
0
votes
1
answer
98
views
Do I need to validate the Request in Controller after?
I have this StoreMessageRequest
public function rules(): array {
return [
'message' => [
'required',
'string',
'max:60',
...
1
vote
1
answer
2k
views
Laravel 10 custom rule: Argument #3 ($fail) must be of type Closure, array given
I want to create a custom rule in Laravel 10. I used php artisan rule:make ValidPackageItem, and this class is generated
<?php
namespace App\Rules;
use Closure;
use Illuminate\Contracts\...
1
vote
0
answers
54
views
Laravel 10 Validation - is it possible to merge nested attributes into one
This is the error I am getting at the moment:
Illuminate\Support\ViewErrorBag {#1725 ▼ // resources/views/components/forms/form.blade.php
#bags: array:1 [▶
"default" => Illuminate\...