Function: icalendar-valarm-validator
icalendar-valarm-validator is a byte-compiled function defined in
icalendar-parser.el.gz.
Signature
(icalendar-valarm-validator NODE)
Documentation
Additional validator function for icalendar-valarm components.
Checks that NODE has the right properties corresponding to its
icalendar-action type, e.g., that an EMAIL alarm has a
subject (icalendar-summary) and recipients (icalendar-attendee).
This function is called by icalendar-ast-node-valid-p for
VALARM nodes; it is not normally necessary to call it directly.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/icalendar-parser.el.gz
(defun ical:valarm-validator (node)
"Additional validator function for `icalendar-valarm' components.
Checks that NODE has the right properties corresponding to its
`icalendar-action' type, e.g., that an EMAIL alarm has a
subject (`icalendar-summary') and recipients (`icalendar-attendee').
This function is called by `icalendar-ast-node-valid-p' for
VALARM nodes; it is not normally necessary to call it directly."
(let* ((action (ical:ast-node-first-child-of 'ical:action node))
(duration (ical:ast-node-first-child-of 'ical:duration node))
(repeat (ical:ast-node-first-child-of 'ical:repeat node))
(child-counts (ical:count-children-by-type node)))
(when (and duration (not repeat))
(ical:signal-validation-error
(concat "`icalendar-valarm' node with `icalendar-duration' "
"must also have `icalendar-repeat' property")
:node node))
(when (and repeat (not duration))
(ical:signal-validation-error
(concat "`icalendar-valarm' node with `icalendar-repeat' "
"must also have `icalendar-duration' property")
:node node))
(let ((action-str (upcase (ical:text-to-string
(ical:ast-node-value action)))))
(cond ((equal "AUDIO" action-str)
(unless (<= (alist-get 'ical:attach child-counts 0) 1)
(ical:signal-validation-error
(concat "AUDIO `icalendar-valarm' may not have "
"more than one `icalendar-attach'")
:node node))
node)
((equal "DISPLAY" action-str)
(unless (= 1 (alist-get 'ical:description child-counts 0))
(ical:signal-validation-error
(concat "DISPLAY `icalendar-valarm' must have "
"exactly one `icalendar-description'")
:node node))
node)
((equal "EMAIL" action-str)
(unless (= 1 (alist-get 'ical:summary child-counts 0))
(ical:signal-validation-error
(concat "EMAIL `icalendar-valarm' must have "
"exactly one `icalendar-summary'")
:node node))
(unless (= 1 (alist-get 'ical:description child-counts 0))
(ical:signal-validation-error
(concat "EMAIL `icalendar-valarm' must have "
"exactly one `icalendar-description'")
:node node))
(unless (<= 1 (alist-get 'ical:attendee child-counts 0))
(ical:signal-validation-error
(concat "EMAIL `icalendar-valarm' must have "
"at least one `icalendar-attendee'")
:node node))
node)
(t
;; "Applications MUST ignore alarms with x-name and iana-token
;; values they don't recognize." So this is not a validation-error:
(ical:warn
(format "Unknown ACTION value in VALARM: %s" action-str)
:buffer (ical:ast-node-meta-get node :buffer)
:position (ical:ast-node-meta-get node :value-begin))
node)))))