Stream Data Min String Length Filter

I am trying to generate strings which pass a rule, e.g.

1 < length(string) < 10

So I am using,

StreamData.string( … ) |> StreamData.filter(..)

but, for some reason, I see the data sent thru the filter is always a single character.

The filter filters out everything…

Of course, without the filter, I rarely see single character outputs.

Obviously I am missing something.

The filter in this case is for individual generated characters, instead of complete strings(?)

Can you please provide a full example of the “generator” you use and its output?

2 Likes

I am just realising, that StreamData.string/2s documentation tells you that it shares options with StreamData.list_of/2. There we have :min_length and :max_length options. So StreamData.string(:ascii, min_length: 2, max_length: 9) should be totally fine.

2 Likes

Sweet, just the answer I needed : )

Moreover, having just started parameter testing and gotten this to work, I just found a bug in a regex - this is great! : )