Skip to content

Commit 5f0584f

Browse files
committed
Update uuid_field function to replace '-' and '_' with random digits for enhanced uniqueness
1 parent 7aea820 commit 5f0584f

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

cuenca_validations/types/helpers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import datetime as dt
2+
import random
23
import uuid
34
from base64 import urlsafe_b64encode
45
from typing import Callable, Optional, Union
@@ -13,7 +14,8 @@
1314
def uuid_field(prefix: str = '') -> Callable[[], str]:
1415
def base64_uuid_func() -> str:
1516
base64_str = urlsafe_b64encode(uuid.uuid4().bytes).decode()[:-2]
16-
sanitized = base64_str.replace('-', 'A').replace('_', 'B')
17+
rnd = str(random.randint(0, 9))
18+
sanitized = base64_str.replace('-', rnd).replace('_', rnd)
1719
return prefix + sanitized
1820

1921
return base64_uuid_func

0 commit comments

Comments
 (0)