ClojureDocs

Nav

Namespaces

?

  • (? pred-form)
Returns a regex op that matches zero or one value matching
pred. Produces a single value (not a collection) if matched.
1 Example
;; Think of this as a regex like "ab?"
(s/def ::ab (s/cat :a #{:a}
                   :b (s/? #{:b})))

(s/valid? ::ab [:a :b])
; => true

(s/valid? ::ab [:a])
; => true

(s/valid? ::ab [:a :c])
; => false
See Also

Returns a regex op that matches one or more values matching pred. Produces a vector of matches

Added by bfontaine
0 Notes
No notes for ?