Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event date validation #85

Open
chantastic opened this issue Mar 24, 2021 · 0 comments
Open

Event date validation #85

chantastic opened this issue Mar 24, 2021 · 0 comments

Comments

@chantastic
Copy link
Contributor

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);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant