1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// This file is part of helpers4.
// Copyright (C) 2025 baxyz
// SPDX-License-Identifier: LGPL-3.0-or-later
/// Checks whether `s` is a UUID in its canonical `8-4-4-4-12` hyphenated hexadecimal form.
///
/// Case-insensitive. The variant and version digits are not checked, so this accepts any RFC
/// 9562 UUID (v1 through v8) as well as the all-zero nil UUID; it only checks the shape.
///
/// # Arguments
///
/// - `s` - The text to check.
///
/// # Returns
///
/// `true` when `s` has the shape of a UUID.
///
/// # Examples
///
/// ```
/// use helpers4::validate::is_uuid;
///
/// assert!(is_uuid("550e8400-e29b-41d4-a716-446655440000"));
/// assert!(is_uuid("550E8400-E29B-41D4-A716-446655440000"));
/// assert!(!is_uuid("550e8400-e29b-41d4-a716-44665544000")); // one digit short
/// assert!(!is_uuid("not-a-uuid"));
/// ```