drgif / limpa

MIT License
0 stars 0 forks source link

map->entity fails with unknown error #1

Closed drgif closed 3 years ago

drgif commented 3 years ago

How to reproduce:

(ns tarefas-core.use-cases
  (:require [limpa.entity :as entity]
            [limpa.use-case :as uc]
            [tarefas-core.entity.todo :as todo]))

(uc/defusecase create-todo!
  [todo-map]
  (let [todo (entity/map->entity todo-map todo/template)]
    (println (str "Todo " (::todo/title todo) "created at " (::todo/created-at todo)))
    (uc/make-success "Todo successfully created" todo)))

(create-todo! {::todo/title       "VITodo"
               ::todo/description "This is my Todo description"})
drgif commented 3 years ago

Handle spec defaults differently: Simplify map->entity to use deep-merge with subsequent (valid?) call.

Consider making a central registry in entity to store defaults for each spec. Could use a macro that calls (s/fdef) and registers the default.

drgif commented 3 years ago

The map with default values for the merger would still be generated by calling (explain-data) on an empty map. EDIT: There is (spec/get-spec) which should make this a lot easier

drgif commented 3 years ago

Fixed in https://github.com/mwiederhold/limpa/commit/9cfe5260753d15ad20260ad2a4443ff3c9d41848 but does not work with nested entities