Column names in message bag spaces
NoxxieNl opened this issue · 2 comments
Hiya,
Love the work you are doing,
I am currently implementing the package for my own project.
However I have an existing database with column names all in uppercase. When an error occurs the message will be shown as:
0 => "The i m p h r e f e r e n c e has already been taken."
The column name is IMPH_REFERENCE :-)
Is there a way to to turn of the spacing (because of the capital letters)?
Hi there - great to hear.
All the validation stuff under the hood is handled by Laravel's validator. It's this component that will format the column's name as it sees fit. Your best bet around it is to provide custom validation messages for the field in question which will allow you to format it as you need.
Hope this helps.
For users having the same problem I had, I dug into the source and found out that on your model add a protected variable $validationAttributeNames
with an array of original names and the naming you want it do be :-).
Example:
protected $validationAttributeNames = [
'IMPH_REFERENCE' => 'reference',
];
There is currently (as of Laravel 5.7) not a option to allow overwriting the formatting option on the :attribute
value of the messages.