Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ark/type/__tests__/keywords/uuid.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,14 @@ contextualize(() => {
'must be a UUIDv4 (was "f70b8242-dd57-5e6b-b0b7-649d997140a0")'
)
})

it("rejects partial matches", () => {
const Uuid = type("string.uuid")
attest(Uuid("dbb1e8e0-40fc-4c14-87eb-61b25d166a1b extra").toString()).snap(
'must be a UUID (was "dbb1e8e0-40fc-4c14-87eb-61b25d166a1b extra")'
)
attest(Uuid("prefix dbb1e8e0-40fc-4c14-87eb-61b25d166a1b").toString()).snap(
'must be a UUID (was "prefix dbb1e8e0-40fc-4c14-87eb-61b25d166a1b")'
)
})
})
2 changes: 1 addition & 1 deletion ark/type/keywords/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ export const uuid = Scope.module(
"#nil": "'00000000-0000-0000-0000-000000000000'",
"#max": "'ffffffff-ffff-ffff-ffff-ffffffffffff'",
"#versioned":
/[\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}/i,
/^[\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,
v1: regexStringNode(
/^[\da-f]{8}-[\da-f]{4}-1[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,
"a UUIDv1"
Expand Down
Loading