Should fail to create invalid rule

This commit is contained in:
Bryce Covert
2023-01-06 16:39:09 -08:00
parent ad5841135a
commit f502d0974e

View File

@@ -55,6 +55,10 @@
(assert-admin (:id context))
(let [existing-transaction (tr/get-by-id id)
account-total (reduce + 0 (map (fn [x] (:percentage x)) accounts))
_ (try
(. java.util.regex.Pattern (compile description java.util.regex.Pattern/CASE_INSENSITIVE))
(catch Exception e
(throw (ex-info (ex-message e) {:validation-error (ex-message e)}))))
_ (when-not (dollars= 1.0 account-total)
(let [error (str "Account total (" account-total ") does not reach 100%")]
(throw (ex-info error {:validation-error error}))))