Fork me on GitHub

could someone point me to some real world examples of conform? I have a hunch that it would be very useful for me, especially with specs like s/or, but I haven’t found the output to be especially easy to adapt, for example in a cond statement.


here’s an example that I think is overly verbose:, would appreciate any tips on trimming this down


is there some existing function that gives me the same value that the predicates/specs in :fn receive?


I am assuming no, but it's probalby not too difficult to create


this seems to work


Hey, what are uses for the :opts key spec on maps? As additional keys are allowed anyways and all present keys are being validated even if they are not in the explicit spec there does not seem to be any relevance for validation. Is it for generation? Something else I’m missing?


nblumoe AFAIK it’s for generation and as documentation


The guide says this: “ When conformance is checked on a map, it does two things - checking that the required attributes are included, and checking that every registered key has a conforming value. We’ll see later where optional attributes can be useful. Also note that ALL attributes are checked via keys, not just those listed in the :req and :opt keys. Thus a bare (s/keys) is valid and will check all attributes of a map without checking which keys are required or optional.” I do not know what “We’ll see later where optional attributes can be useful” is referring to

Alex Miller (Clojure team)14:01:17

They are used in generators (as well as serving as doc)

Alex Miller (Clojure team)14:01:44

@luxbock the :fn spec receives a map {:args …, :ret …} where the values are the conformed values of the args and ret specs. you don’t need that get-fspec-attr - you can call (s/get-spec sym) to get the fspec and that supports ILookup, so you can (:args (s/get-spec sym)) to get (for example) the args spec.


@alexmiller: thanks, yeah figured there might have been a better way