A way better approach for form validation. Feels good now.

This commit is contained in:
2022-07-19 08:24:33 -07:00
parent b84600e4f1
commit cab3a84903
18 changed files with 530 additions and 111 deletions

View File

@@ -0,0 +1,19 @@
(ns auto-ap.schema
(:require [malli.core :as m]))
(def reference (m/schema [:map [:id :string]]))
(def date (m/schema [:fn
(fn [d]
(if-not (or (instance? goog.date.DateTime d)
(instance? goog.date.Date d))
(throw (ex-info "Invalid Date" {:type ::m/invalid-type}))
true))]))
(def money (m/schema [float? {:error/message "Invalid money"}]))
(def not-empty-string (m/schema [:re {:error/message "Required"} #"\S+"]))
(def expense-account (m/schema [:map
[:id :string]
[:account reference]
[:location :string]
[:amount money]]))