Skip to content

Provide regular expressions and JSON schemas for UUIDs #498

@goloroden

Description

@goloroden

Hi 👋

I'm one of the authors of the uuidv4 module.

With the new 8.3 version of uuid there is almost everything there that is needed from our POV, and we are planning to deprecate uuidv4 in favor of this module.

However, there are two very small things missing, before we can do this:

First, it would be awesome to have regular expressions for UUIDs.
In uuidv4 we use the following ones:

const regex = {
  v4: /(?:^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}$)|(?:^0{8}-0{4}-0{4}-0{4}-0{12}$)/u,
  v5: /(?:^[a-f0-9]{8}-[a-f0-9]{4}-5[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}$)|(?:^0{8}-0{4}-0{4}-0{4}-0{12}$)/u
};

Besides, it would be great to have JSON schemas for UUIDs. Again, we're using this code here, which builds on top of the aforementioned regexs:

const jsonSchema = {
  v4: { type: 'string', pattern: regex.v4.toString().slice(1, -2) },
  v5: { type: 'string', pattern: regex.v5.toString().slice(1, -2) }
};

Unfortunately, we are missing the time to update the uuid module ourselves, however this should be fairly easy to integrate.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions