Answers for "laravel validation code"

PHP
7

laravel validation example

//import		
		use Illuminate\Support\Facades\Validator;
	
		// single var check
        $validator = Validator::make(['data' => $value],
            ['data' => 'string|min:1|max:10']
        );
        if ($validator->fails()) {
            // your code
        }

        // array check
        $validator = Validator::make(['data' => $array],
            ['email' => 'string|min:1|max:10'],
            ['username' => 'string|min:1|max:10'],
            ['password' => 'string|min:1|max:10'],
            ['...' => '...']
        );

        if ($validator->fails()) {
            // your code
        }
Posted by: Guest on April-17-2020
2

laravel validation show

<!-- /resources/views/post/create.blade.php -->

<h1>Create Post</h1>

@if ($errors->any())
    <div class="alert alert-danger">
        <ul>
            @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
        </ul>
    </div>
@endif

<!-- Create Post Form -->
Posted by: Guest on August-22-2020
1

laravel validation

/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    Validator::extend(...);

    Validator::replacer('foo', function ($message, $attribute, $rule, $parameters) {
        return str_replace(...);
    });
}
Posted by: Guest on December-25-2020
0

validation required in laravel

Request()->validate([
            'nik' => 'required',
            'nama' => 'required',
            'alamat' => 'required',
            'notelp' => 'required',
            'jk' => 'required',
            'agama' => 'required',
            'pekerjaan' => 'required',
            'status' => 'required',

        ], [
            'nik.required' => 'nik Wajib Diisi!',
            'nama.required' => 'nama perolehan Wajib Diisi!',
            'alamat.required' => 'alamat Wajib Diisi!',
            'notelp.required' => 'notelp Wajib Diisi!',    
            'jk.required' => 'jk Wajib Diisi!',        
            'agama.required' => 'agama habis Wajib Diisi!',
            'pekerjaan.required' => 'pekerjaan Wajib Diisi!',
            'status.required' => 'status Wajib Diisi!',
        ]);
Posted by: Guest on October-09-2021

Code answers related to "laravel validation code"

Browse Popular Code Answers by Language