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

Error messages for "required_unless_all" rule is not using field labels #364

Closed
mattscooter opened this issue Jan 29, 2018 · 3 comments
Closed

Comments

@mattscooter
Copy link

I am attempting to validate a form where I have firstName, lastName and companyName fields. I want to validate that at least one of them is entered. I am using validatorjs as my validation engine.

It looks like required_without_all is working the way I expect, except that the message I am getting isn't quite right. The error message text has the field names rather than labels for the other fields.

Expected result:
"The First Name field is required when Last Name, Company Name are empty."

Actual result:
"The First Name field is required when lastName, companyName are empty."

Is there any way to get the error message to display the labels?

Note I am using separated definition since I have nested fields in my real world example.

Config:

  fields = [
    'firstName',
    'lastName',
    'companyName'
  ];
  
  rules = {
    firstName: 'string|required_without_all:lastName,companyName',
    lastName: 'string|required_without_all:firstName,companyName',
    companyName: 'string|required_without_all:firstName,lastName'
  };
  
  labels = {
    firstName: 'First Name',
    lastName: 'Last Name',
    companyName: 'Company'
  }

Versions:
validatorjs: 3.14.2
mobx-react-form: 1.32.3

@foxhound87
Copy link
Owner

Can you check if the issue is not related to the validation lib?

@mattscooter
Copy link
Author

Looks like it may be an issue with the validatorjs library.

This bug raised against the library has similar problem but with the required_if rule. When that gets fixed I will check if it's working ok.
mikeerickson/validatorjs#232

@foxhound87
Copy link
Owner

🎉 This issue has been resolved in version 1.35.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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