Function: icalendar-ast-node-valid-p

icalendar-ast-node-valid-p is a byte-compiled function defined in icalendar-ast.el.gz.

Signature

(icalendar-ast-node-valid-p NODE &optional RECURSIVELY)

Documentation

Check that NODE is a valid iCalendar syntax node.

By default, the check will only validate NODE itself, but if RECURSIVELY is non-nil, it will recursively check all its descendants as well. Signals an icalendar-validation-error if NODE is invalid, or returns NODE.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/icalendar-ast.el.gz
(defun ical:ast-node-valid-p (node &optional recursively)
  "Check that NODE is a valid iCalendar syntax node.
By default, the check will only validate NODE itself, but if
RECURSIVELY is non-nil, it will recursively check all its
descendants as well.  Signals an `icalendar-validation-error' if
NODE is invalid, or returns NODE."
  (unless (ical:ast-node-p node)
    (ical:signal-validation-error
     "Not an iCalendar syntax node"
     :node node))

  (ical:ast-node-valid-value-p node)
  (ical:ast-node-valid-children-p node)

  (let* ((type (ical:ast-node-type node))
         (other-validator (get type 'ical:other-validator)))

    (unless (ical:type-symbol-p type)
      (ical:signal-validation-error
       (format "Node's type `%s' is not an iCalendar type symbol" type)
       :node node))

    (when (and other-validator (not (functionp other-validator)))
      (ical:signal-validation-error
       (format "Bad validator function `%s' for type `%s'" other-validator type)))

    (when other-validator
      (funcall other-validator node)))

  (when recursively
    (dolist (c (ical:ast-node-children node))
      (ical:ast-node-valid-p c recursively)))

  ;; success:
  node)