   "Updates the specified entity"
   [storage-spec entity]
   (with-storage [s storage-spec]
-    (let [validated (validate-existing-entity s entity)]
+    (let [validated (validation/validate ::existing-entity entity)]
       (if (validation/valid? validated)
         (do
           (->> validated

  "Creates a new entity"
  [storage-spec entity]
  (with-storage [s storage-spec]
    (let [validated (validate-new-entity s entity)]
      (when (not validated)
        (throw (ex-info "The validated data is null" {:entity entity
                                                      :validated validated})))
      (if (validation/has-error? validated)
        validated
        (->> validated
             before-save
             (create-entity s ))))))

(defn select
  "Returns entities for the specified user"

(ns clj-money.models.entities
  (:refer-clojure :exclude [update])
  (:require [clojure.pprint :refer [pprint]]
            [clojure.spec :as s]
            [clojure.tools.logging :as log]
            [clojure.set :refer [rename-keys]]
            [clojure.reflect :refer :all]
            [clj-money.validation :as validation]
            [clj-money.models.helpers :refer [with-storage]]
            [clj-money.models.storage :refer [create-entity
