DateTimeValidator: DateTimeRanges without local_timezone #25
Labels
enhancement
Improvements to existing features or smaller new features
question
Further information is requested
Milestone
Currently it is possible to use DateTimeValidator with datetime ranges but without setting local_timezone. This can lead to problems when either the input datetime is a local datetime or the datetime range boundaries are local datetimes (comparing local datetimes with timezoned datetimes will raise a TypeError).
Currently there is this note in the class documentation:
Instead of just warning in the documentation, it might be a good idea to catch these edge cases already at validator creation (i.e. in
__init__()
): If the DateTimeFormat is one that allows local datetimes AND a range is defined AND local_timezone is NOT set: Raise anInvalidValidatorOptionException
.Not sure though whether there might be usecases where you don't want to define a local_timezone (e.g. you only allow local datetimes (
DateTimeFormat.LOCAL_ONLY
) and you define a range that has local datetimes as boundaries too).The text was updated successfully, but these errors were encountered: