From f502d0974e0879b2f8398f99cdaa063084a1776b Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Fri, 6 Jan 2023 16:39:09 -0800 Subject: [PATCH] Should fail to create invalid rule --- src/clj/auto_ap/graphql/transaction_rules.clj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/clj/auto_ap/graphql/transaction_rules.clj b/src/clj/auto_ap/graphql/transaction_rules.clj index f703bb4e..4c3064f3 100644 --- a/src/clj/auto_ap/graphql/transaction_rules.clj +++ b/src/clj/auto_ap/graphql/transaction_rules.clj @@ -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}))))