diff --git a/ark/type/__tests__/keywords/uuid.test.ts b/ark/type/__tests__/keywords/uuid.test.ts index 0a204adede..3bd966dd5a 100644 --- a/ark/type/__tests__/keywords/uuid.test.ts +++ b/ark/type/__tests__/keywords/uuid.test.ts @@ -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")' + ) + }) }) diff --git a/ark/type/keywords/string.ts b/ark/type/keywords/string.ts index 05064933b5..0779d70a55 100644 --- a/ark/type/keywords/string.ts +++ b/ark/type/keywords/string.ts @@ -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"