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

Email field is required but marked as nullable in ICalAttendeeData type #467

Closed
koenigstag opened this issue Mar 3, 2023 · 2 comments
Closed

Comments

@koenigstag
Copy link

koenigstag commented Mar 3, 2023

ical-generator version: 3.6.1

Recently tested simple email with attendees and discovered that none of falsy values are valid for email field in attendees array.

interface ICalAttendeeData {
  ...
  email?: string | null;
  ...
}

Tested values are: undefined, null, "" (empty string).
Example code

attendees: [
  {
    name: "Test User",
    email: null
  }
]

This example gives an error:
"No value for `email` in ICalAttendee given!"

CodeSandbox:
https://codesandbox.io/s/express-typescript-example-forked-94ujl7?file=/src/routes.ts

@sebbo2002
Copy link
Owner

This is sadly true for all mandatory fields in ical-generator. The reason for this is that ical-generator has always allowed you to use the setters, in this case email() for example, and you are not required to include all the data with the constructor. This is currently absolutely valid code, for example:

const attendee = event.createAttendee();
attendee.email('foo@bar.com');

I understand that this is a bit weird, but I hope that the exceptions is meaningful enough. For the next breaking version it is already planned that at least the mandatory fields have to be passed to achieve some security here.

@sebbo2002
Copy link
Owner

I just pushed a preview of ical-generator v6 to develop, which should fix this issue. I would be happy if you could test the new version and give me some feedback. You can install the version with npm i ical-generator@next. All changes in this release can be found here.

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

2 participants