Fork me on GitHub
#malli
<
2020-07-26
>
mike_ananev11:07:51

Hi! How I can express if A is optional in schema and if A exists then B should present too?

borkdude11:07:56

probably using a predicate?

mike_ananev11:07:37

I mean how to express it as spec (inside spec one value depends on another) ?

mike_ananev11:07:14

{
 :java-src-folder             "test-projects/javac/src/java"
 :javac-options               ["-target" "1.8" "-source" "1.8" "-Xlint:-options"] }
How to express as spec if :java-src-folder is present then :javac-options should be present?

ikitommi11:07:37

@mike1452 you can compose rules with :and, from README: `(-> [:and [:map [:password string?] [:password2 string?]] [:fn {:error/message "passwords don't match" :error/path [:password2]} '(fn [{:keys [password password2]}] (= password password2))]] (m/explain {:password "secret" :password2 "faarao"}) (me/humanize)) ; {:password2 ["passwords don't match"]}`