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'm sorry if this is answered somewhere, I tried searching here and read the Readme twice, and analyzed the error method in the src and cannot figure out how to do this, or if it's even possible.
Currently I can repeat back the name of the field that failed its validation in the error message by using {field}, however for debugging purposes I was trying to add {value} and it does not work. I checked the error() method at runtime and the $values array that gets passed is empty so the $params array it creates for the vsprintf call is empty.
How can I write my rule so the $values param that is passed to the error method is populated?
Here is the code I am currently using:
$this->validator->rule('required', 'primaryNtpServer');
$this->validator->rule('optional', 'secondaryNtpServer');
$this->validator->rule(function ($field, $value) {
if ($field === 'secondaryNtpServer' && empty($value)) {
returntrue;
}
returnServices::dateTime()::verifyNtpdServer($value);
}, ['primaryNtpServer', 'secondaryNtpServer'], [)->message('{field} "{value}" did not respond to an NTP request.');
The text was updated successfully, but these errors were encountered:
I'm sorry if this is answered somewhere, I tried searching here and read the Readme twice, and analyzed the error method in the src and cannot figure out how to do this, or if it's even possible.
Currently I can repeat back the name of the field that failed its validation in the error message by using
{field}
, however for debugging purposes I was trying to add{value}
and it does not work. I checked theerror()
method at runtime and the$values
array that gets passed is empty so the$params
array it creates for thevsprintf
call is empty.How can I write my rule so the
$values
param that is passed to theerror
method is populated?Here is the code I am currently using:
The text was updated successfully, but these errors were encountered: