You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am writing code to validate array of emails and phone numbers as follow
var rules = {
'emails[]': 'required_without:phones[]|array',
'emails[].*': 'required|email',
'phones[]': 'required_without:emails[]|array',
'phones[].*': 'required|digits_between:9,10',
};
var messages = {
'required_without.emails[]': 'Email is required when no any phones is not present',
'array.emails[]': 'Emails must be an array',
'required.emails[].*': 'Email is required',
'email.emails[].*': 'Email must be a valid email address',
'required_without.phones[]': 'Phone is required when no any emails is not present',
'array.phones[]': 'Phones must be an array',
'required.phones[].*': 'Phone is required',
'digits_between.phones[].*': 'Phone must be between :min and :max digits'
};
When process of validate the result as follow
{
"emails[].0": ["The emails .0 field is required."],
"emails[].1": ["The emails .1 field is required."],
"emails[].2": ["The emails .2 field is required."],
"emails[].3": ["The emails .3 field is required."]
}
The error message was not override even I set it in messages 'required.emails[].*': 'Email is required'
How can I solve this issue?
The text was updated successfully, but these errors were encountered:
@cnakh Would you be able to share a bit more code? I can see how you have defined the rules and messages but I am not sure how you are invoking the validator, and seeing how the incoming data appears, I can advise further.
I am writing code to validate array of emails and phone numbers as follow
When process of validate the result as follow
The error message was not override even I set it in messages
'required.emails[].*': 'Email is required'
How can I solve this issue?
The text was updated successfully, but these errors were encountered: