We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
After upgrading to v5.2.2, my translations are not loaded anymore. The problem lies with the third argument passed to Validator::extend.
Problem Code:
Validator::extend('currency_code', function ($attribute, $value, $parameters, $validator) use(&$currency_code) { $status = false; $currency_code = $value; $currencies = config('money.currencies'); if (array_key_exists($value, $currencies)) { $status = true; } return $status; }, trans('validation.custom.invalid_currency', ['attribute' => $currency_code]) );
Suggested Solution: To fix this, use the Validator::replacer method to dynamically load translations during validation:
Validator::extend( 'currency_code', function ($attribute, $value, $parameters, $validator) { $status = false; $currencies = config('money.currencies'); if (array_key_exists($value, $currencies)) { $status = true; } return $status; } ); Validator::replacer('currency_code', function ($message, $attribute, $rule, $parameters) { return trans('validation.custom.invalid_currency', ['attribute' => $attribute]); });
The text was updated successfully, but these errors were encountered:
No branches or pull requests
After upgrading to v5.2.2, my translations are not loaded anymore. The problem lies with the third argument passed to Validator::extend.
Problem Code:
Suggested Solution:
To fix this, use the Validator::replacer method to dynamically load translations during validation:
The text was updated successfully, but these errors were encountered: