nette / schema

📐 Validating data structures against a given Schema.
https://doc.nette.org/schema
Other
886 stars 26 forks source link

Add DateTime and DateTimeRange expectations #36

Open repli2dev opened 3 years ago

repli2dev commented 3 years ago

It would be handy to provide expectations for datetime too, typically validation & parsing in given format. Apart from format typically we use min and max validations as well as cross validations for intervals between two or more provided values.

dg commented 3 years ago

It would probably be better to make a separate class for this, like https://github.com/redbitcz/subreg-api-php/blob/60f377ac68f3c1871b926eca336f5eb8d3368455/src/Schema/DateTime.php

deba12 commented 3 years ago

I like the idea for both Date and DateTime. At the moment we are using assert to validate Date/DateTime, then we still have to use Date/DateTime to make some comparisons and so on. This example from subreg-api-php is cool, it returns Date/DateTime object. @dg could you please implement it?