REGEXVAULTv2.0
Identity & PII/Consent & Compliance
Verified Safe

GDPR Consent Record ID Regex for JavaScript

/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i

What this pattern does

This page provides a well-structured, multi-part regular expression for matching gdpr consent record id, ported and verified for JavaScript. Identity and credential patterns need both correctness and safety, since they're frequent targets for adversarial input. The snippet below is ready to drop into your JavaScript project — whether you're validating in an Express middleware, a Next.js API route, or a client-side form.

Javascript Implementation

Javascript
// GDPR Consent Record ID
// ReDoS-safe | RegexVault — Identity & PII > Consent & Compliance

const gdprConsentRecordIdRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;

function validateGdprConsentRecordId(input: string): boolean {
  return gdprConsentRecordIdRegex.test(input);
}

// Example
console.log(validateGdprConsentRecordId("550e8400-e29b-41d4-a716-446655440000")); // true

Test Cases

Matches (Valid)
Rejects (Invalid)
550e8400-e29b-41d4-a716-446655440000550e8400-e29b-41d4-a716-44665544000
6ba7b810-9dad-41d1-80b4-00c04fd430c8550e8400e29b41d4a716446655440000
xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx

When to use this pattern

This pattern is drawn from the Identity & PII > Consent & Compliance category and carries a ReDoS-safe certification. That matters for JavaScript developers because especially critical in long-running Node.js event loops where a ReDoS vulnerability can block the entire process. RegexVault audits patterns against known backtracking attack vectors, ensuring you have the necessary context before using this regex in a high-stakes production environment.

Common Pitfalls

Consent records must be retained as long as the data is processed (and for the limitation period of any regulatory claim). Deleting consent records along with user data is a common compliance mistake.

Technical Notes

Consent records under GDPR Article 7 must be documented with: who consented, when, what they consented to, and how. UUID v4 is the standard format for consent record IDs. Link the consent ID to: user ID, timestamp, purpose, version of privacy notice, withdrawal date (if applicable).

Have a pattern that belongs in the vault?

Submit it for review — community-verified patterns get credited to your GitHub handle. Free submissions join the queue. Priority review available for $15.

Submit a Pattern