d0c-s4vage / lookatme

An interactive, terminal-based markdown presenter
https://lookatme.readthedocs.io/en/latest/
MIT License
2.08k stars 61 forks source link

Invalid date error from marshmallow validation #147

Closed maxmahlke closed 1 year ago

maxmahlke commented 2 years ago

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:

  1. Create md file
  2. Add date: 01/09/2022 in metadata header
  3. Launch lookatme pointing to the slides md file
  4. 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

d0c-s4vage commented 1 year ago

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.

d0c-s4vage commented 1 year ago

Actually, I'll cut a new release and get this fix out