chrra / iCalendar

iCalendar data types, parser, and printer.
BSD 3-Clause "New" or "Revised" License
38 stars 47 forks source link

Is `DTSTART` mandatory? #40

Open KommuSoft opened 4 years ago

KommuSoft commented 4 years ago

If I generate a calendar with an event, that has no DTSTART (so with veDTStart=Nothing), I obtain the following calendar:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//haskell.org/NONSGML iCalendar-0.4.0.5//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTSTAMP:20200829T000000Z
UID:20200829
CREATED:20200829T155830Z
END:VEVENT
END:VCALENDAR

But when validating this, with https://icalendar.org/validator.html#results this reports the error that:

Missing DTSTART property in VEVENT near line # 5
    Reference: RFC 5545 3.6.1. Event Component

It looks like DTSTART is thus mandatory, and thus perhaps its type should be a DTStart instead of a Maybe DTStart.

NorfairKing commented 1 year ago

@KommuSoft The spec says:

                  ;
                  ; The following is REQUIRED if the component
                  ; appears in an iCalendar object that doesn't
                  ; specify the "METHOD" property; otherwise, it
                  ; is OPTIONAL; in any case, it MUST NOT occur
                  ; more than once.
                  ;
                  dtstart /
KommuSoft commented 1 year ago

Well I'm wondering if we can do some type system magic to make it impossible to use Nothing in case the Method is not specified, making it thus impossible to have an invalid calendar (or at least for this specific field).

NorfairKing commented 1 year ago

@KommuSoft Having recently implemented, I now believe you can't do this at the type-level: https://github.com/NorfairKing/ical

That's what Validity is for.