Skip to content

Conversation

@xDivisionByZerox
Copy link
Member

Description

This PR solves #3699.

The PR introduces support for generating UUID v7 values via faker.string.uuid({ version: 7 }). This extends the existing function with a time ordered variant based on the Unix timestamp. To preserve the current behavior, an explicit signature for faker.string.uuid({ version: 4 }) (the default) has also been added.

Since UUID v7 is time‑based, the new API allows providing a reference date (refDate) argument as well.

A few implementation choices differ slightly from the usual patterns in this project:

  • The core functionality is implemented in standalone functions that are then used by the module. This approach has several advantages:
    • It keeps both the UUID algorithm and the public API easier to read.
    • It makes the public API more naturally extensible for future UUID versions.
    • It simplifies a potential future transition toward standalone functions (see Proposal: Design for standalone module functions #2667).
  • The UUID API now exposes multiple signatures. The goal is to make the relationship between the refDate argument and the selected version clearer. Another benefit is that the default signature can retain its original since tag (v8.0.0).
    For documentation generation to work correctly, an additional signature mirroring the implementation is required, and this one must appear last. You can verify this in the documentation preview for this PR.

Link

@xDivisionByZerox xDivisionByZerox added this to the v10.x milestone Jan 22, 2026
@xDivisionByZerox xDivisionByZerox requested a review from a team January 22, 2026 18:19
@xDivisionByZerox xDivisionByZerox self-assigned this Jan 22, 2026
@xDivisionByZerox xDivisionByZerox requested a review from a team as a code owner January 22, 2026 18:19
@xDivisionByZerox xDivisionByZerox added the c: feature Request for new feature label Jan 22, 2026
@xDivisionByZerox xDivisionByZerox linked an issue Jan 22, 2026 that may be closed by this pull request
@xDivisionByZerox xDivisionByZerox added p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug m: string Something is referring to the string module labels Jan 22, 2026
@netlify
Copy link

netlify bot commented Jan 22, 2026

Deploy Preview for fakerjs ready!

Name Link
🔨 Latest commit 7c766cc
🔍 Latest deploy log https://app.netlify.com/projects/fakerjs/deploys/69751a7edb3ef4000822261d
😎 Deploy Preview https://deploy-preview-3701.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.97%. Comparing base (8f5954a) to head (7c766cc).
⚠️ Report is 2 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #3701      +/-   ##
==========================================
- Coverage   99.97%   99.97%   -0.01%     
==========================================
  Files        2995     2996       +1     
  Lines      236323   236245      -78     
  Branches      941      950       +9     
==========================================
- Hits       236266   236187      -79     
- Misses         57       58       +1     
Files with missing lines Coverage Δ
src/modules/string/index.ts 100.00% <100.00%> (ø)
src/modules/string/uuid.ts 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Co-authored-by: Shinigami <chrissi92@hotmail.de>
Shinigami92
Shinigami92 previously approved these changes Jan 22, 2026
@xDivisionByZerox xDivisionByZerox requested a review from a team January 23, 2026 19:44
Copy link
Contributor

@matthewmayer matthewmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also mention this as one of the methods listed in
https://fakerjs.dev/guide/usage#reproducible-results

Co-authored-by: Matt Mayer <152770+matthewmayer@users.noreply.github.com>
@xDivisionByZerox
Copy link
Member Author

should we also mention this as one of the methods listed in fakerjs.dev/guide/usage#reproducible-results

I don't think this is necessary, since these are only examples and not a comprehensible list. Or did you mean to replace one of the examples from the date module with this method, to get more diversity in the examples?

@matthewmayer
Copy link
Contributor

should we also mention this as one of the methods listed in fakerjs.dev/guide/usage#reproducible-results

I don't think this is necessary, since these are only examples and not a comprehensible list. Or did you mean to replace one of the examples from the date module with this method, to get more diversity in the examples?

Yeah good idea

version?: 4 | 7;
/**
* The timestamp to encode into the UUID.
* This parameter is only relevant for time based UUID's.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one needs a fix too for consistency.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. You gave me a suggestion block and I took the easy way of simply committing it inside of GH without looking around first. I'll do better next time. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: feature Request for new feature m: string Something is referring to the string module p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for UUIDv7 Generation

4 participants