Skip to content

Unexpected matches behavior #61

Description

@jumarko

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions