-
-
Notifications
You must be signed in to change notification settings - Fork 254
Open
Description
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)) {
return true;
}
return Services::dateTime()::verifyNtpdServer($value);
}, ['primaryNtpServer', 'secondaryNtpServer'], [)->message('{field} "{value}" did not respond to an NTP request.');Metadata
Metadata
Assignees
Labels
No labels