I’m trying to add regex to the route.
My idea is to check for correct date format - yyyy-mm-dd.
I want to call my api like so:
/api/check/2019-12-05/2019-12-10
In the route, use a simple from:[12]\d{3}\-\d{2}\-\d{2} type check, and then in the route controller use the library - a validator of the vlucas/valitron type.
@Misiu your implementation is ok if you is using Validator for this route only. In the future if you find yourself writing more stuff like this you could rewrite for a better implementation.
But the thing I noticed is your route pattern, for me wasn’t clear that your were checking dates between a period. Using the dates as query params wouldn’t be better? Something like: /api/check?from=2019-12-05&to=2019-12-10?
I’m just bringing this to topic putting myself as consumer of the API.