Add support for datetime in strict mode#256
Conversation
ad4aef3 to
afbaab2
Compare
|
I'd like to discuss what exactly the format check should do. Unfortunately ISO 8601 is quite permissive when it comes to the allowed variants of the format. RFC 3339 is much stricter: Full date and time and time zone, date and time separated by "T", fractional seconds indicated by a dot, time zone either "Z" or an hour:minute offset. Any valid RFC 3339 string also is a valid ISO 8601 string, but not vice versa. In addition, even if we ignore the vast possibilities of ISO 8601 and focus on what PHP thinks is ISO 8601, the annotation for In addition, all these changes currently are undocumented. My question is: Is it worth it to enforce any specific date format that is stricter than what More generically asked: Is it useful for this library to gain the ability to at least partially validate the data, or should this best be left to dedicated JSON schema validators (which I would recommend doing, but that's a personal opinion and preference)? |
|
Hi @SvenRtbg, your reasoning is definitely valid. Another option I was considering was to extend the library with an optional |
|
I'm following this library for some time now, and whenever someone suggests to just add another configuration option, all I can think of is that it will at least duplicate the test cases (which is true for any boolean) and make understanding the library itself more and more complex. So my question would be: Can we align the DateTime case with anything that already exists and can act as the template? As that would be much more in line with existing developer expectation. And there is something alike: Enums are basically treated the same way, whatever string is representing the Enum is thrown into One idea may be calling On the other hand, if passing the scalar into the constructor the same way as is expected with non-strict checking, then any validation is obviously wrong, should be omitted, and does not need to introduce any configuration. The original issue ticket asks for a way to allow |
Fixes #240
bStrictObjectTypeChecking.