A set of custom validators for validating date and datetime fields for Django.
- Install the package using pip:
pip install django-datetime-validators
- Add
datetime_validators
toINSTALLED_APPS
INSTALLED_APPS = [
...,
"datetime_validators",
]
Checks if a date is in the future.
from datetime_validators.validators import date_time_is_future_validator
# Using in Models
due_date = models.DateTimeField(
validators=[date_time_is_future_validator]
)
- date_is_future_validator: Checks if a date is in the future.
- date_is_present_or_future_validator: Ensures that a date is either in the present or in the future.
- date_is_past_validator: Validates that a date is in the past.
- date_is_present_or_past_validator: Checks if a date is either in the present or in the past.
- date_time_is_future_validator: Validates if a datetime is in the future.
- date_time_is_present_or_future_validator: Checks if a datetime is either in the present or in the future.
- date_time_is_past_validator: Ensures that a datetime is in the past.
- date_time_is_present_or_past_validator: Validates that a datetime is either in the present or in the past.
Contributions are more than wellcome :)