Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Required if another field not empty #144

Open
Rashid2kaz opened this issue Nov 17, 2021 · 2 comments
Open

Required if another field not empty #144

Rashid2kaz opened this issue Nov 17, 2021 · 2 comments

Comments

@Rashid2kaz
Copy link

Hello!
I have 2 fields - 'password' and 'confirm_password'.
I need:

  1. If 'password' empty - 'confirm_password' not required.
  2. If 'password' not empty - 'confirm_password' is required.

How do I describe the rules?

@Tropicalista
Copy link

Have you tried with:

$validation` = $validator->make($_POST + $_FILES, [
    'password'              => 'required|min:6',
    'confirm_password'      => 'same:password',
]);

@Rashid2kaz
Copy link
Author

Have you tried with:

$validation` = $validator->make($_POST + $_FILES, [
    'password'              => 'required|min:6',
    'confirm_password'      => 'same:password',
]);

Password can be empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants