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

GDPR Consent Record ID Regex for Go

/^[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 Go. 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 Go project — whether you're validating in a Gin handler, a gRPC service, or a command-line tool.

Go Implementation

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

package validation

import "regexp"

var gdprConsentRecordIdRe = regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$`)

func ValidateGdprConsentRecordId(s string) bool {
    return gdprConsentRecordIdRe.MatchString(s)
}

// Example
// fmt.Println(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 Go developers because Go's RE2 engine is inherently safe from catastrophic backtracking, but this pattern has been additionally verified for correctness. 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