Skip to content

Pass max-tries to such-that #5

Description

@arichiardi

Very often I receive the dreaded:

expected: nil
  actual: clojure.lang.ExceptionInfo: Couldn't satisfy such-that predicate after 10 tries.
 at clojure.core$ex_info.invokeStatic (core.clj:4617)
    clojure.core$ex_info.invoke (core.clj:4617)

Especially with this schema:

(defn lt
  "Return a constrained schema that is valid iff (< (count %) size).
  The schema parameter therefore needs to be Countable."
  [schema size]
  (s/constrained schema #(< (count %) size)))

(def NonEmptyStr (s/constrained s/Str #(not (empty? (str/trim %))) "non-empty string"))

(def UserId {:email (lt NonEmptyStr 40)})

I was checking and such-that can increase the number of tries:
https://clojure.github.io/test.check/clojure.test.check.generators.html#var-such-that

Maybe we can have a dynamic var to pass in there?

PS: Is the above a good way to handle that case? I am still pretty new to schema.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions