Skip to content

Commit 9468eaa

Browse files
authored
fix false negative check on UUID v7 and v8
As per [RFC9562](https://datatracker.ietf.org/doc/html/rfc9562#table2) uuid v7 and v8 exists and are thus are perfectly valid versions.
1 parent d99b6ff commit 9468eaa

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/rules/uuid.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
const PATTERN = /^([0-9a-f]{8}-[0-9a-f]{4}-[1-6][0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}|[0]{8}-[0]{4}-[0]{4}-[0]{4}-[0]{12})$/i;
3+
const PATTERN = /^([0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}|[0]{8}-[0]{4}-[0]{4}-[0]{4}-[0]{12})$/i;
44

55
/** Signature: function(value, field, parent, errors, context)
66
*/
@@ -21,7 +21,7 @@ module.exports = function({ schema, messages }, path) {
2121
const version = val.charAt(14) | 0;
2222
`);
2323

24-
if(parseInt(schema.version) < 7) {
24+
if(parseInt(schema.version) < 9) {
2525
src.push(`
2626
if (${schema.version} !== version) {
2727
${this.makeError({ type: "uuidVersion", expected: schema.version, actual: "version", messages })}
@@ -40,6 +40,8 @@ module.exports = function({ schema, messages }, path) {
4040
case 3:
4141
case 4:
4242
case 5:
43+
case 7:
44+
case 8:
4345
if (["8", "9", "a", "b"].indexOf(val.charAt(19)) === -1) {
4446
${this.makeError({ type: "uuid", actual: "value", messages })}
4547
}

0 commit comments

Comments
 (0)