Category : validation

getting the error ErrorException: preg_match(): Unknown modifier ‘)’ in file C:wampwwwabcdappRulesHtmlstring.php on line 35 for below code. $rules = [‘cartTemplate’=>[‘required’,new Htmlstring],]; class Htmlstring implements Rule { public function passes($attribute, $value) { return preg_match(‘/<(/)?(body|html|head|p|b|strong|a|i|span|div)*>/’,$value); } } Sourc..

Read more

<div><img src="https://ci6.googleusercontent.com/proxy/wi-WlYQ2m5IHeGEPm0tMCvanR7D802PRaMo5KxVyrzjaIIzhK61fM3DLzlNomULyXCpB4zsBQQ=s0-d-e1-ft#https://cdn.gmass.co/images/logo.png" alt="ABCD" class="CToWUd"> <div>Hello JenTenPen,</div><div>You have applied multiple vouchers to your cart.</div><ul><li>New year loyalty applied on cart is going to expire on Monday, 11 October, 2021 at 11:44 PM</li><li>Special promotion applied on Maths Course is going to expire on Monday, 11 October, 2021 at 11:44 PM</li></ul><div>Kindly make your purchase soon to avail these discounts.</div><div>With ..

Read more

Quero validar o login do usuário que pode ser por documento (cnpj, cpf) ou e-mail. Porém não sei como fazer o validador pros dois ao mesmo tempo. Separados eles funcionam assim: class ValidateEmailRequest extends FormRequest { public function rules(Request $request): array { if (isset($request->email)) { $rule_mail = ‘required|email|min:10|max:150’; } else { $rule_mail = ‘unique:users,email|required|email|min:10|max:150’; } ..

Read more

How to edit text "validation.unique" in laravel 8 ? My Controller public function customRegistration(Request $request) { $request->validate([ ‘name’ => ‘required’, ‘role_id’ => ‘required’, ‘username’ => ‘required|unique:tbl_users’, ‘password’ => ‘required|min:12’, ‘status_id’ => ‘required’ ]); $data = $request->all(); $check = $this->create($data); if ($request->role_id == 2) { return redirect("admin-master/show_vendor")->with(‘success’, ‘Pengguna Berhasil Di Daftarkan’); }else{ return redirect("admin-master/show_pengawas")->with(‘success’, ‘Pengguna Berhasil ..

Read more

i have a problem i want to have an showing errormessage if a user uses a false mimetype in the uploadprocess. I cant find the real statement or argument to declare what it should do. public function rules() { return [ ‘season_name’ => ‘required|unique:seasons,name’, ‘thumbnail’ => ‘required|mimes:png,jpg’ ]; } public function messages() { return [ ..

Read more

The below code shows the error TypeError: Argument 1 passed to AppHttpControllersStudentLearningController::abc() must be an instance of IlluminateHttpRequest, array given class StudentLearningController extends Controller{ public function abc(){ $myCourseData[‘points’] = "1"; $myCourseData[‘totalPoints’] = "2"; $this->update($myCourseData,$myCourseId); } } i wanted to pass 2 parameters: points & totalPoints from function abc() to the function update() and access points ..

Read more

Laravel 8 validation. I say with eg: table name football ,1 column name->team ,2 column->player name 3 sports items required . team name player name sports item required (this column is drop ) 1 man u kane 1 football 2 boat 3 jersey ———————————————————————————————- 2 man u john 2 boat 3 jersey here sports item ..

Read more

$myCourseData[‘points’] = "1"; $myCourseData[‘totalPoints’] = "2"; $this->update($myCourseData,$myCourseId); i wanted to pass points & totalPoints from a function to the function update() and access points in update() as $request->points;.How can i do that? Only points & totalPoints are passed from the above function , other params in the update() function input are getting from somewhere else. ..

Read more

i always used reuqest validation inside the controller method directly but i have seen lots of laravel developers suggesting the use of a FormRequest object and injecting it in the controller method as a replacement for request , yes it looks cleaner and straight forward when it comes to customizing some validation rules or messages ..

Read more

I have 2 different tables based on their types: User & Buyer. I am validating "buyers" data but it checks in the "users" table rather than in the "buyers" table, Is there any way to ask Validator Facade to check in the "buyers" table. $validator = Validator::make($request->all(), [ ‘name’ => ‘required’, ‘user_type’ => ‘required’, ‘phone’ ..

Read more

I have three Fields title body images[] the body is required without image, so I did the following: $request->validate([ ‘title’ => ‘required|string|max:’ . (int) Setting::getValue(‘titlemaxchars’), ‘body’ => [ ‘required_without:images’, ‘string’, ‘min:’.(int) Setting::getValue(‘postminchars’), ‘max:’.(int) Setting::getValue(‘postmaxchars’), ], ]); if ($request->hasFile(‘images’)) { foreach ($request->file(‘images’) as $file) { Validator::validate([‘photo’ => $file], [ ‘photo’ => [‘required’, ‘file’, ‘image’, ‘max:2048’], ]); ..

Read more

I am working on returning validation errors in multiple languages at the same time. I have a controller that injects a class that extends FormRequest and I am overriding ‘failedValidation’ and there I get the validator error messages. public function store(SysUserStoreRequest $request) { // … } class SystemUserStoreRequest extends ApiRequest { // This extends another ..

Read more

blog:{ postTitle: ”, } this is in JS let data = new FormData(); const blog = JSON.stringify(this.blog); data.append(‘blog’,blog); Laravel $blog = json_decode(request(‘blog’)); $blog->validate([ ‘blog.postTitle’ => ‘required’ ]); I have tried to: after I decode it I have tried to: return $request[‘blog’] and it works. Error for validation I get is: Call to undefined method stdClass::validate() ..

Read more

I have a request data like this. image I want to validate the input teacher, schedule and classroom like this: if schedule, teacher and classroom are duplicate or if schedule and teacher duplicate, but different classroom I’ve tried with rule::unique as below but validation doesn’t work. how to make validation of point 1 and 2 ..

Read more

The Problem I’m working on Invoice Lines. When the line type is ‘Text Only’ the price and quantity fields should be blank. When the line type is ‘Item’ the price and quantity fields are required. What Laravel already does: The required_if function works perfectly for saying "OK it’s an item line, require the quantity and ..

Read more