Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

ValidateUUIDMBS(UUID as string, mode as Integer = 0, requiredVersion as Integer = 0) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Encryption and Hash MBS Util Plugin 12.3 Yes Yes Yes Yes No
Function: Validates the given UUID/GUID.
Example:
// wrong
dim w1 as string = ValidateUUIDMBS("hello") // wrong due to missing {
dim w2 as string = ValidateUUIDMBS("550e8400-z29b-11d4-a716-446655440000",1) // wrong with, with z
dim w3 as string = ValidateUUIDMBS("{550e8400-e29b-11d40716-446655440000}") // wrong with missing minus
dim w4 as string = ValidateUUIDMBS("{550e8400-e29b-11d4-a716-44665544000}") // wrong with being too short
dim w5 as string = ValidateUUIDMBS("{550e8400-e29b-11d4-a716-446655440000}dssdsd",1) // wrong as it has extra chars on end
dim w6 as string = ValidateUUIDMBS("550e8400-e29b-11d4-a716-446655440000",1,4) // wrong as not version 4
dim w7 as string = ValidateUUIDMBS("6a12a4d5-e9e6-4568-ffcc-34c70b24a668",1,4) // wrong as not version 4

// okay
dim o1 as string = ValidateUUIDMBS("550e8400-e29b-11d4-a716-446655440000",1)
dim o2 as string = ValidateUUIDMBS("{550e8400-e29b-11d4-a716-446655440000}")
dim o3 as string = ValidateUUIDMBS("6a12a4d5-e9e6-4568-afcc-34c70b24a668", 1)
dim o4 as string = ValidateUUIDMBS("6a12a4d5-e9e6-4568-afcc-34c70b24a668", 3)
dim o5 as string = ValidateUUIDMBS("{550e8400-e29b-11d4-a716-446655440000}", 2)
dim o6 as string = ValidateUUIDMBS("{550e8400e29b11d4a716446655440000}", 2)
dim o7 as string = ValidateUUIDMBS("{550e8400-e29b-11d40716-446655440000}",4) // wrong with missing minus, but fixed
dim o8 as string = ValidateUUIDMBS("550e8400-e29b-11d40716-446655440000}",4) // wrong with missing {, but fixed
dim o9 as string = ValidateUUIDMBS("6a12a4d5-e9e6-4568-afcc-34c70b24a668", 4, 4) // is version 4
dim o10 as string = ValidateUUIDMBS("6a12a4d5-e9e6-1568-afcc-34c70b24a668", 4, 1) // is version 1
dim o11 as string = ValidateUUIDMBS("{550e8400-e29b-11d4-a716-446655440000}dssdsd",1+4) // wrong as it has extra chars on end, but fixed

break // check in debugger
Notes:
If the UUID is valid, you get it back.
If the UUID is invalid, you get an empty string back.

Pass 1 in mode to not require braces around UUID. Pass 2 to ignore minus characters. Pass 3 to combine those two.
You can add 4 to have the GUID fixed a bit like adding braces and minus chars if missing.
The requiredVersion parameter can be 1 to 5 to indicate the required GUID version you want to have.

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Util Plugin.





Links
MBS Xojo PDF Plugins