Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

96
Views
Laravel validation for ensuring difference in values

For the below code , i don't want the password field to have the same value of currentPassword field. The desired output is to show some validation error like "password & currentPassword canot be the same" ,when one types same value for both password & currentPassword fields. To be more precise, it should work in opposite of the rule - same does.

$validator = Validator::make(
            $request->all(),
            [
                'currentPassword'     => 'required',
                'password' => 'required|min:6|confirmed',
            ]
        );
8 months ago · Santiago Trujillo
1 answers
Answer question

0

You would expect the rule to be named "NotSame", but it is not. Instead the validation rule is called different.

'password' => 'different:currentPassword'
8 months ago · Santiago Trujillo Report
Answer question
Find remote jobs