Ah thanks, that worked, not quite as I expected. Up until this point it was
pretty straightforward for me, thats been my fist bummer.
Do you have an example for this in the guide? I did not fully read it, but
I think I scrolled through everything that used fdefs.
Best Regards,
Sven
Am Donnerstag, 26. Mai 2016 12:21:15 UTC+2 schrieb Alex Miller:
>
> It's a little tricky but you want:
>
> (s/fdef remove-autoinc-columns :args (s/cat :cols (s/spec ::columns)))
>
> Here the args data is ([{:foo "some_t"}]) and while you have an s/cat for
> :args and an s/cat in ::columns, those will be combined into the same regex
> so that's basically the same thing as ::columns. You need to force a new
> level of regex context and the s/spec will do that.
>
> On Thursday, May 26, 2016 at 4:32:52 AM UTC-5, Sven Richter wrote:
>>
>> Hi,
>>
>> I already asked this in the spec channel on slack, but got no response
>> yet.
>>
>> I have this simple spec definition:
>>
>> (s/def ::foo string?)
>>
>>
>>
>> (s/def ::column (s/keys :req-un [::foo]))
>>
>>
>>
>> (s/def ::columns (s/cat :col (s/* (s/spec ::column))))
>>
>> ;(s/def ::columns (s/cat :col (s/* ::column)))
>>
>>
>>
>> (defn remove-autoinc-columns [cols]
>>
>> (vec (remove #(= true (:autoinc %)) cols)))
>>
>>
>>
>> (s/fdef remove-autoinc-columns :args (s/cat :cols ::columns)
>>
>> :ret ::columns)
>>
>>
>>
>>
>> $(remove-autoinc-columns [{:foo "some_t"}])
>>
>> ===> ExceptionInfo Call to
>> #'de.sveri.clospcrud.s-play/remove-autoinc-columns did not conform to spec:
>>
>> At: [:args] val: ([{:foo "some_t"}]) fails predicate: (cat :cols
>> :de.sveri.clospcrud.s-play/columns), Extra input
>>
>> :clojure.spec/args ([{:foo "some_t"}])
>>
>> clojure.core/ex-info (core.clj:4617)
>>
>>
>> On the other hand, running this:
>> (s/conform ::columns [{:foo "some_t"}])
>> => {:col [{:foo "some_t"}]}
>> works.
>>
>> So something is broken within the fdefs argument definition.
>>
>> I dont see my mistake here, can somone else reproduce / fix this?
>>
>> Thanks,
>> Sven
>>
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.