phrase
phrase copied to clipboard
Fail to match coll-of min-count predicate
Hi, Thanks a lot for this library!
I have defined the following spec:
(s/def ::colors (s/coll-of string? :kind vector? :min-count 1))
And the following phrasers:
(phrase/defphraser :default
[_ problem]
problem)
(phrase/defphraser #(clojure.core/<= min-count (clojure.core/count %) max-count)
[_ {:keys [val]} min-count max-count]
(str min-count))
When running phrase-first
with the following input:
(phrase/phrase-first {} ::colors [])
I expect the 2nd phraser to be matched, but actually the default phraser is matched:
{:path [],
:pred (clojure.core/<= 1 (clojure.core/count %) Integer/MAX_VALUE),
:val [],
:via [:my-project.schema/colors],
:in [],
:phrase.alpha/mappings {:x0 1},
:phrase.alpha/via ()}
Any ideas what am I missing? Thanks!
This is my min-count phraser (which works):
(defphraser (cljs.core/<= min (cljs.core/count %) 9007199254740991)
[_ problem min]
(problem->err problem "min-count" #(str "Must contain at least "
(formatting/pluralize %1 min))))