У меня есть класс формы бронирования, определенный как
class Booking(FlaskForm):
room_type= HiddenField()
check_in=DateField("Arrival Date", [validators.Required("Select Arrival Date")], format='%Y-%m-%d')
check_out=DateField("Departure Date", [validators.Required("Select Departure Date")], format='%Y-%m-%d')
adults = TextField("Adults",[validators.Required("No of Adults travelling are Mandatory!")])
children = TextField("Children")
name_booking = TextField("Name",[validators.Required("First Name is Mandatory!")])
email_booking = EmailField("email ",[validators.Required("email is Mandatory!")])
submit = SubmitField("Send")
Я хочу построить логику, в которой регистрация всегда меньше, чем проверка.Я попробовал
def chkdate(form, field):
if field.data > check_in.data:
raise ValidationError('Check Out cannot be before Check In')
class Booking(FlaskForm):
room_type= HiddenField()
check_in=DateField("Arrival Date", [validators.Required("Select Arrival Date")], format='%Y-%m-%d')
check_out=DateField("Departure Date", [validators.Required("Select Departure Date"), chkdate()], format='%Y-%m-%d')
adults = TextField("Adults",[validators.Required("No of Adults travelling are Mandatory!")])
на основе WTF Docs