mercredi 6 juin 2018

Laravel 5.2 Query String Parameter Validation

I am currently doing a small project to learn some laravel validation and ran into a problem. The API endpoint is api/test/schoolbook?start= and my validation is 'start' => ['date_format:Y-m-d H:i:s']

While this works like a charm and sorts the schoolbooks by a start year, i think my validation has some error. It validates if start is equal to the defined date format, all good. but if i now parse just ?start=without any thing, it still goes through, but doesn't throw an error message (it just returns everything without sorting)

Is there a way i can validate this better and prevent the query string parameter to be empty?

Thank you!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire