You're on the right track.. This is not the answer you're looking for but it might help in your journey to building something amazing...I THINK...
The validator is to make sure what client is entering into our application is valid if not send response back to user to correct it, not to clean it up for them. So my suggestion to you is validate the field for **integer" (Yes Laravel has that that rule already) if client enter something other than integer tell them to enter an integer.
Sometimes for whatever reason something didn't work and you ended getting unwanted data, or perhaps do just don't trust the validation to do its job, or that is where Laravel's mutators comes in handy. You can cleanup or do whatever you want with the data before saving it to the database. You can actually call the Regex within the mutator.
I hope that helps.
Sign in to participate in this thread!
We'd like to thank these amazing companies for supporting us