dimanche 4 septembre 2016

Laravel 5.3 - Custom validators

I have this validator for input called "name":

http://Regex:/^[A-Za-z0-9\\s\\-\\/,.]*$/|min:5|max:50

But, I want to use this validator in multiple forms in my website. How can i do this without to copy this validator in all the forms validations?

My database contains table called "settings", every row presents setting of the website. Each setting contain Json code that save the setting data. I want to create custom validator that check if the input value equals to one of the values in the Json code in my database. I have Json code like this:

[{"US":"United States", "UK":"United Kingdom"}]

And I want to check if the value of the input equals to one of the values in the Json code. How can I do this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire