Fork me on GitHub
#malli
<
2022-12-05
>
Ben Sless05:12:53

Should and generators use bind in reverse order to allow for transformers? Sort of like specs conforming

dharrigan18:12:22

I wonder if anyone may have an example of using {:gen/gen ....} to generate a random email address for a malli schema?

pithyless18:12:19

on my phone, but are you familiar with https://github.com/gfredericks/test.chuck? I’ve previously used string-from-regex for this. I’ve also more recently been using the faker library with malli to generate reasonable looking data if you’re not testing the extremes of the data itself (and don’t need smart shrinking)

Ben Sless18:12:09

I can whip one up if you'd like Tldr is I'd break it down to its components first, then compose their generators

pithyless18:12:47

with generators I think the question is always what’s “interesting” and in scope for the “purpose” of the output. If you’d like to test the limitations of the email string itself @UK0810AQ2 approach of composing from smaller generators is sound.

dharrigan18:12:31

I figured it out

dharrigan18:12:37

thre is an undocumented re-gen!!!

til 1
dharrigan18:12:50

It pays to look at the source code

dharrigan18:12:13

[:foo/email-address [:re {:gen/re-gen [email-pattern]} email-pattern]]

Ben Sless18:12:26

Yeah but the email regex is a monster

dharrigan18:12:47

Yeah, it's hairy, been there before on validating email. I'll take a pragmatic approach.

Noah Bogart19:12:03

is there any difference between [:id :int] and [:id int?]?

til 1
Noah Bogart19:12:25

I tried to search but it's kind of nebulous lol

pithyless19:12:01

They have implementation differences that leak into your code in surprising ways (if you're not aware of them). I suggest using :int by default. :) See e.g: https://github.com/metosin/malli/issues/636 https://github.com/metosin/malli/issues/327

Noah Bogart19:12:19

ah yeah, i remember seeing that a while back. that's annoying

Abhinav16:12:07

This was very interesting