(define-condition validation-error (error) ((errors :reader errors :initarg :errors)) (:default-initargs :errors (error "Must provide ERRORS."))) (defun validate-post (title title-supplied-p path path-supplied-p) (let ((errors '())) (when title-supplied-p (unless (post-title-p title) (setf errors (acons 'title "Invalid title" errors)))) (when path-supplied-p (unless (post-path-p path) (setf errors (acons 'path "Invalid path" errors)))) errors)) (defun update-post (post &key (title nil title-supplied-p) (path nil path-supplied-p)) (let ((errors (validate-post title title-supplied-p path path-supplied-p))) (when errors (error 'validation-error :errors errors)) (setf (slot-value post 'title) title (slot-value post 'path) path) (mito:save-dao post)))