isValidUUIDv4 static method

bool isValidUUIDv4(
  1. String uuid
)

Validates whether a string is a valid UUIDv4.

Implementation

static bool isValidUUIDv4(String uuid) {
  /// Regular expression pattern for UUIDv4
  final pattern = RegExp(
    r'^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$',
  );

  /// Check if the input string matches the pattern
  return pattern.hasMatch(uuid);
}