/* * SPDX-FileCopyrightText: 2023 jordi fita mas * SPDX-License-Identifier: AGPL-3.0-only */ package uuid import "dev.tandem.ws/tandem/camper/pkg/hex" func Valid(s string) bool { if len(s) != 36 { return false } // it must be of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx if s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' { return false } for _, x := range [16]int{ 0, 2, 4, 6, 9, 11, 14, 16, 19, 21, 24, 26, 28, 30, 32, 34} { if !hex.Valid(s[x], s[x+1]) { return false } } return true }