Skip to content

Event date validation #85

Description

@chantastic

Until #79, we were validating the event date before building them.

I'm opening this issue to hold the implementation for future discussion of a similar implementation:

// Some helpers to make sure our event frontmatter is :100:
// Make events have an eleventy and js-yaml-friendly standardized date format of:
// date: 2021-01-11T21:00:00-08:00
// See: https://www.11ty.dev/docs/dates/#setting-a-content-date-in-front-matter
// Note: we make sure the parsed date is valid, then check the actual raw input format to make sure we have consistency

// const dateFormatRegex = /(date:)\s[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}Z/gm;
const isValidDate = (date, rawInputContent) => {
  !Number.isNaN(Date.parse(date)) && rawInputContent.match(dateFormatRegex);
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions