malli 2025-03-19

Wesley Matson (RemixAI work) 2025-03-19T16:12:58.202709Z

Is there a straightforward way to say that the schema of something is any valid malli schema? e.g. I want to create something for fancy string interpolation that’d take an input like the following, and I want to make a schema for this input:

["Please create a backstory for a character with the name " 
 {:name :char-name :type [:string]} 
 " the age " {:name :age :type [:int]} 
 " and the class " {:name :char-class :type [:enum "warrior" "mage" "ranger"]}]

Wesley Matson (RemixAI work) 2025-03-19T16:13:22.988199Z

So far, I have something like this: but I’d like to replace the :any with something that means “any valid malli schema”

[:seqable
   [:or
    [:string]
    [:map
     [:name :keyword]
     [:type :any]]]]

hack: something like [:fn m/schema]

👀 1

cool idea for string templating

❤️ 1
Wesley Matson (RemixAI work) 2025-03-19T16:22:29.058379Z

🤔 the hack seems to work for validation, but I was hoping the solution might also work for coercion with string transformation (essentially, I want these to roundtrip cleanly through JSON for external API purposes, which I realize may be a little unrealistic)

Wesley Matson (RemixAI work) 2025-03-19T16:25:07.026219Z

If I do only the vector syntax for schemae and don’t allow the options maps, I can probably get away with something like this, but that’ll have some other drawbacks (and maybe I can just use this or similar for the first step of coercion and do a second pass with the hack for validation)

[:seqable
   [:or
    [:map
     [:name :keyword]
     [:type [:vector [:or :keyword [:vector :keyword]]]]]
    [:string]]]

do you have a corpus of the sorts of schemas you want to handle? maybe you could get halfway there with the malli schema provider stuff

Wesley Matson (RemixAI work) 2025-03-19T16:30:43.108749Z

That’s a good idea, I have five-ish examples, though they don’t really represent the full intended breadth, that’ll probably get me started. (although the string interpolation is the easiest-to-explain reason I want the ability to say the value of this schema is “any valid schema”)