membrane-php / membrane-core

Membrane is a general purpose input validation library, supports both PHP Attributes and OpenAPI specifications
Other
1 stars 2 forks source link

Add strict mode to date string validator, #138

Closed carnage closed 1 year ago

carnage commented 1 year ago

Adds a strict mode which validates that the date string can be turned into the expected date.

eg 2022-13-05 passes the date format Y-m-d but creates the date 2023-01-05

Strict mode confirms that the date not only matches the format but comes out the same when formatted that way from the date time object. This check will fail if PHP's datetime object changes the date value from what was passed in order to turn it into a valid date.

This behaviour cannot be the default as some date format strings eg Y-m-d| do not produce the same result when used in \DateTime->format() calls.