"""
Author: Michel Peltriaux
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
Contact: ksp-servicestelle@sgdnord.rlp.de
Created on: 17.05.23

"""
from datetime import datetime

from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _


def reasonable_date(value):
    """ Validator which checks that no dates like "01.01.1" can be entered

    Args:
        value ():

    Returns:

    """
    min_date = datetime.fromisoformat("1950-01-01").date()
    if value < min_date:
        raise ValidationError(
            _("This date is unrealistic. Please enter the correct date (>1950)."),
            params={"value": value},
        )
