Fork me on GitHub
#malli
<
2022-11-17
>
hanDerPeder13:11:01

Is this a bug?

(m/validate :at.least/ten 8
            {:registry (merge
                        (m/default-schemas)
                        {:at.least/ten [int? {:min 10}]})}) ;; => true, but 8 < 10

hanDerPeder13:11:32

I would expect the props from the vector to be passed to the schema.

(m/properties
 (m/schema :at.least/ten
           {:registry (merge
                       (m/default-schemas)
                       {:at.least/ten [int? {:min 10}]})})) ;; => nil

ikitommi13:11:37

int? is just a predicate, does not support properties, :int is a real schema. Try [:int {:min 10}] instead.

ikitommi13:11:56

would be nice to get a warning out of this, but not there yet.

juhoteperi13:11:43

@U055NJ5CC predicate schemas probably support some properties, just not these

hanDerPeder13:11:47

aha, thanks 👍 this would imply that there is not a real schema equivalent of inst? , right? how come?

ikitommi13:11:45

there is a separate ticket for making good time schemas, e.g. :time, :date , …

ikitommi13:11:29

but, bumped into the missing :inst just yesterday, so, hear you.

juhoteperi13:11:31

(defn -int-schema [] (-simple-schema {:type :int, :pred int?, :property-pred (-min-max-pred nil)})) and int? is (-simple-schema {:type 'int?, :pred int?})

👍 1
juhoteperi13:11:16

We could register property-pred for predicates where it makes sense

juhoteperi13:11:29

.... though I might prefer just removing property predicates completely

hanDerPeder13:11:07

I second that, speaking as a relatively new user coming from spec I expected int? and :int to be equivalent

hanDerPeder13:11:26

but to end I would just like to say you guys but out some amazing libraries. i've learned a ton from reading your code. thanks!

👍 1
hanDerPeder13:11:27

shouldn't this also work?

(m/properties
 (m/schema :at.least/ten
           {:registry (merge
                       (m/default-schemas)
                       {:at.least/ten [:int {:doc "this number needs to be at least ten"
                                             :custom/attrib :tranmogrify
                                             :min 10}]})}))
ie, I expect schema properties to be returned, but is nil

hanDerPeder13:11:42

aha, malli.core/deref

ikitommi16:11:32

m/coercer and m/coerce landed on master. Runs decode + validate, throws with explain result in case of error. Have copied those fns once too many times between projects.

❤️ 10
👌 3