Commit 96a97683 by Triyah Fatmawati

Validasi regex password registrasi

parent 91acc65d
...@@ -48,12 +48,10 @@ class RegisterController extends Controller ...@@ -48,12 +48,10 @@ class RegisterController extends Controller
*/ */
protected function validator(array $data) protected function validator(array $data)
{ {
$regex = "^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-_]).{8,}$";
return Validator::make($data, [ return Validator::make($data, [
'name' => ['required', 'string', 'max:255'], 'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
// 'password' => ['required', 'string', 'min:8', 'confirmed', regex($regex)], 'password' => ['required', 'string', 'min:8', 'confirmed'],
'password' => "required|regex:/^(?=.?[A-Z])(?=.?[a-z])(?=.?[0-9])(?=.?[#?!@$%^&*-_]).{8,}$/|min:8|confirmed",
]); ]);
} }
......
...@@ -60,6 +60,14 @@ class UserController extends Controller ...@@ -60,6 +60,14 @@ class UserController extends Controller
*/ */
public function store(UserRequest $request) public function store(UserRequest $request)
{ {
// dd($request);
$request->validate([
'password' => 'required|regex:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$/|min:8|confirmed',
], [
'password.required' => 'Password wajib diisi',
'password.regex' => 'Password tidak aman! Harus kombinasi angka, huruf kapital, huruf kecil, dan karakter',
'password.min' => 'Password minimal 8 karakter',
]);
$user = auth()->user(); $user = auth()->user();
$data = $request->except('_token'); $data = $request->except('_token');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment