-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
I have a case class with a lot of members that yields well to generating an Arbitrary
instance using scalacheck-shapeless, but some individual field values I'd like to discard as invalid.
For that purpose, I wanted to generate the instance using this library, call filter
on it and make the result of that implicit
.
I couldn't find anything in the documentation explaining how to generate an instance without making it implicit.
After some trial and error, I came up with:
implicit val arbitraryFoo: Arbitrary[Foo] = {
val baseArbitrary = implicitly[Strict[MkArbitrary[Foo]]].value.arbitrary.arbitrary
baseArbitrary.filter(validationCheck)
}
Is there a better way I'm missing?
If yes, it should be added to the documentation.
If not, this seems useful and can be implemented (see semiauto
generic derivation in Circe as an example).
matil019, felixbr, jmccance and steinybotasakaev
Metadata
Metadata
Assignees
Labels
No labels