I came across a surprising matches validator behavior: it marks a value as valid when only part of the value satisfies given regex:
(b/valid? {:name "ab"} {:name [v/required v/string [v/matches #"\w{1,2}"]]})
;;=> true
(b/valid? {:name "abc"} {:name [v/required v/string [v/matches #"\w{1,2}"]]})
;; should be false
;;=> true
(re-matches #"\w{1,2}" "abc")
;;=> nil
;; even worse if we expect only digits
(b/valid? {:name "abc123def"} {:name [v/required v/string [v/matches #"\d+"]]})
;;=> true
Is this an expected behavior?
I came across a surprising
matchesvalidator behavior: it marks a value as valid when only part of the value satisfies given regex:Is this an expected behavior?