                         :base64Image      base64_image})) ; base64Image is last so it does not appear in the logs.
       (data-response (str "Institution " institution-id " is not found.")))))
 
-(defn- check-inputs [name description]
+(defn- get-common-errors [name description]
   (cond
     (or (nil? name) (= name ""))
     (str "Name is required.")

        base64-image (:base64Image params)
        url          (:url params)
        description  (:description params)]
    (if-let [error-message (get-create-errors name description)]
      (data-response error-message)
      (if-let [institution-id (sql-primitive (call-sql "add_institution" name url description))]
        (do

          (doseq [admin-id (set [user-id 1])]
            (call-sql "add_institution_user" institution-id admin-id 1))
          (data-response institution-id))
        (data-response "Unknown server error.")))))

(defn- get-update-errors [institution-id user-id name]
  (cond
    (nil? (first (call-sql "select_institution_by_id" institution-id user-id)))
    (str "Institution " institution-id " is not found.")

    (sql-primitive (call-sql "institution_name_taken" name institution-id))
    (str "Institution with the name " name " already exists.")))

(defn update-institution [{:keys [params]}]
  (let [user-id        (:userId params -1)
