2022-10-26 12:41:22 +02:00
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
from marshmallow import ValidationError
|
|
|
|
|
|
|
|
|
|
|
|
def validate_index(index: int) -> None:
|
|
|
|
if len(str(index)) > 6:
|
|
|
|
raise ValidationError("Length of index is too long!")
|
|
|
|
elif len(str(index)) < 6:
|
|
|
|
raise ValidationError("Length of index is too short!")
|
|
|
|
|
|
|
|
|
|
|
|
def validate_datetime_greater_than_now(date: datetime) -> None:
|
2022-10-27 11:19:38 +02:00
|
|
|
if date.timestamp() < datetime.utcnow().timestamp():
|
2022-10-26 12:41:22 +02:00
|
|
|
raise ValidationError("Date must be greater than NOW!")
|