Skip to content

isUuid - Detect if a given keypath contains a valid UUID

isUuid is a function that detects if a given field is a valid UUID. This is incredibly useful for cleaning data, and also for flagging when information may have become malformed.

isUuid returns true if the keypath contains a valid UUID, otherwise false.

Syntax

isUuid(uuid: string): bool

Arguments

Name Type Required Description
uuid string true The candidate UUID value

Example - Flagging invalid / corrupted UUID values

Consider the following document:

{
    "uuid":"0b954eed-de4a-4304-a398-16fbb09cd7e3"
},
{
    "uuid":"0b954eed-de4a-4304-a398-1"
}

We can see that the first UUID is valid, but the second has been cut off and is no longer valid. We may have millions of these documents, so we don't want to manually check them all. Instead, we can use isUuid to flag them:

create is_uuid from isUuid(uuid)

Now, each document will have a flag, is_uuid which is true is the field uuid contains a valid UUID, otherwise it's false, making flagging corrupted values much easier.