Skip to content
Discussion options

You must be logged in to vote

How about randomly choosing between fc.string and fc.uuid ?

const sometimesUuid = fc.oneof(fc.string(), fc.uuid())

With that you get a valid UUID ~50% of the time. If you want a different ratio, you can tweak the weight parameter.

for (const item of fc.sample(sometimesUuid, 20)) {
  console.debug(item)
}
X~GE>~HD{
eString
fffffff6-ffeb-8fff-8000-001098c1bddc
ffffffef-6e8d-7a4b-8f3a-18cdb7b807d5
ffffffed-000d-1000-8000-00010000001a
NSI wUHnc
!"V
5w;3
c15bbc7a-c112-7422-8000-00160000000a

0000000f-7e76-274a-8000-00078b1fe946
ba8d9bb5-0003-1000-bdd0-d2334ba6f53e
f85f494d-1900-63cf-8000-0012ffffffe3
cb742c5d-e7c4-4d9c-9640-5442fffffff0
5ee3736f-cf8e-838d-8000-001600000019
ZHR\}
(!EN!#|%
fffff…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@dubzzz
Comment options

Comment options

You must be logged in to vote
1 reply
@drewgingerich
Comment options

Answer selected by drewgingerich
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants