Invalid date error from marshmallow validation
maxmahlke opened this issue · comments
Describe the bug
I tried setting the date
metadata field using different formats such as date: September 2, 2022
, date: 01/09/2022
yet
kept getting the marshmallow.exceptions.ValidationError: {'date': ['Not a valid date.']}
when launching lookatme
.
The reason is that the date
attribute of the MetaSchema
requires a datetime.datetime
instance. Unless I'm misunderstanding the intended use, a valid date
cannot be set at all via the markdown file.
I changed
date = fields.Date(
default=datetime.datetime.now(),
missing=datetime.datetime.now(),
)
in lookatme/schemas.py
to
date = fields.Str(
default="",
missing="",
)
as for the title
and author
. Now I can set the date to any string. I'd be happy to submit a PR for this if you approve.
To Reproduce
Steps to reproduce the behavior:
- Create
md
file - Add
date: 01/09/2022
in metadata header - Launch
lookatme
pointing to the slidesmd file
- See error
Expected behavior
The date
string should be printed as I define it, no validation necessary.
Environment (please complete the following information):
lookatme, version 2.3.2
Thanks for reporting this! I'm doing a big refactoring of the codebase for a v3.0 - I'll include this in there too! It should only be a week or two away, I've done the bulk of the work already in the 3.0-dev branch.
Actually, I'll cut a new release and get this fix out