malli

roklenarcic 2025-02-09T16:30:18.064329Z

Is it possible to define :keyword schema that limits the size of the keyword?

2025-02-09T16:50:03.053289Z

I would do:

[:and :keyword
      [:fn (fn [k] (< (count (name k)) 10)]]

roklenarcic 2025-02-09T16:52:18.192849Z

yeah I figured that one out already, was hoping for something shorter

ikitommi 2025-02-16T09:20:21.978429Z

PR welcome, just need to add support for :min and :max for :keyword, see string

(defn -string-schema [] (-simple-schema {:type :string, :pred string?, :property-pred (-min-max-pred count)}))

(defn -keyword-schema [] (-simple-schema {:type :keyword, :pred keyword?}))

roklenarcic 2025-02-09T18:42:21.766479Z

Is it possible to have malli drop extra keys from maps when coercing? If I mark map as closed that makes extra keys invalid, I would just like to ignore them remove them from the data structure

2025-02-09T18:44:44.907019Z

look at https://github.com/metosin/malli?tab=readme-ov-file#value-transformation the mt/strip-extra-keys-transformer

👍 1
roklenarcic 2025-02-09T19:21:08.352829Z

Thanks