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"]}]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]]]]🤔 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)
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
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”)