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
What problem does this feature proposal attempt to solve?
I'm struggling with translations, the problem is when returning the validation errors, if the args were nested it spits out something like input.name and it doesnt resolve __('validation.attributes.name') like it would with a normal laravel validator due to the input. prefix
The required translation from the validation.php file in lang directory: 'required' => 'ข้อมูล:attribute จำเป็นต้องกรอก',
Paired with 'attributes' => ['name' => 'TRANSLATION HERE'] in the same file
Lighthouse will spit out: 'input.name' => 'ข้อมูลinput.name จำเป็นต้องกรอก'
Because of the input. prefix, it doesn’t resolve and translate the attribute in the message
Is there a way to get around this without having to duplicate all of the attributes and prefix them with input. (what if it’s nested further, like a relation, you have to duplicate them all further with the same value but a different key
If it’s not currently possible, my proposed solution would be to keep the key the same input.name in the returned error list, but pass through the name from the rules for the message name instead of input.name
This would be a breaking change, so maybe we could make it a toggled feature in the config or a directive or something? Open to suggestions
The text was updated successfully, but these errors were encountered:
I am not planning to work on this myself, but can provide guidance for a pull request. All validation concerns are handled in src/Validation. In order to implement this, look into RulesGatherer and how it is used in ValidateDirective.
Sure, I can try to make a PR soon. Should I make this a toggled feature from the config? That's the only way I can think of implementing this without it being a breaking change.
Yeah, a feature toggle would be great if there is breakage. Allows for a smoother transition to a new major version where we might change the default or remove the toggle.
What problem does this feature proposal attempt to solve?
I'm struggling with translations, the problem is when returning the validation errors, if the args were nested it spits out something like
input.name
and it doesnt resolve__('validation.attributes.name')
like it would with a normal laravel validator due to theinput.
prefixThe required translation from the validation.php file in lang directory:
'required' => 'ข้อมูล:attribute จำเป็นต้องกรอก',
Paired with
'attributes' => ['name' => 'TRANSLATION HERE']
in the same fileLighthouse will spit out:
'input.name' => 'ข้อมูลinput.name จำเป็นต้องกรอก'
Because of the
input.
prefix, it doesn’t resolve and translate the attribute in the messageIs there a way to get around this without having to duplicate all of the attributes and prefix them with
input.
(what if it’s nested further, like a relation, you have to duplicate them all further with the same value but a different keyhttps://laravel.com/docs/9.x/validation#specifying-attribute-in-language-files
Which possible solutions should be considered?
If it’s not currently possible, my proposed solution would be to keep the key the same
input.name
in the returned error list, but pass through the name from the rules for the messagename
instead ofinput.name
This would be a breaking change, so maybe we could make it a toggled feature in the config or a directive or something? Open to suggestions
The text was updated successfully, but these errors were encountered: