Functions

createType1AsRecord
I

Returns a UUID of type 1 as a UUID record.

createType1AsString
I

Returns a UUID of type 1 as a string.

createType3AsRecord
I

Returns a UUID of type 3 as a UUID record.

createType3AsString
I

Returns a UUID of type 3 as a string.

createType4AsRecord
I

Returns a UUID of type 4 as a UUID record.

createType4AsString
I

Returns a UUID of type 4 as a string.

createType5AsRecord
I

Returns a UUID of type 5 as a UUID record.

createType5AsString
I

Returns a UUID of type 5 as a string.

getVersion
I

Detect RFC version of a UUID.

nilAsRecord
I

Returns a nil UUID as a UUID record.

nilAsString
I

Returns a nil UUID as a string.

toBytes
I

Converts to an array of bytes.

toRecord
I

Converts to a UUID record.

toString
I

Converts to a UUID string.

validate
I

Test a string to see if it is a valid UUID.

createType1AsRecord

function createType1AsRecord() returns Uuid | Error
Isolated Function

Returns a UUID of type 1 as a UUID record.

1uuid:Uuid uuid1 = check uuid:createType1AsRecord();

Return Type

(Uuid | Error)

UUID of type 1 as a UUID record or else a uuid:Error

createType1AsString

function createType1AsString() returns string
Isolated Function

Returns a UUID of type 1 as a string.

1string uuid1 = uuid:createType1AsString();

Return Type

(string)

UUID of type 1 as a string

createType3AsRecord

function createType3AsRecord(NamespaceUUID namespace, string name) returns Uuid | Error
Isolated Function

Returns a UUID of type 3 as a UUID record.

1uuid:Uuid uuid3 = check uuid:createType3AsRecord(uuid:NAME_SPACE_DNS, “ballerina.io”);

Parameters

  • namespace NamespaceUUID
  • String representation for a pre-defined namespace UUID

  • name string
  • A name within the namespace

Return Type

(Uuid | Error)

UUID of type 3 as a UUID record or else a uuid:Error

createType3AsString

function createType3AsString(NamespaceUUID namespace, string name) returns string | Error
Isolated Function

Returns a UUID of type 3 as a string.

1string uuid3 = check uuid:createType3AsString(uuid:NAME_SPACE_DNS, “ballerina.io”);

Parameters

  • namespace NamespaceUUID
  • String representation for a pre-defined namespace UUID

  • name string
  • A name within the namespace

Return Type

(string | Error)

UUID of type 3 as a string or else a uuid:Error

createType4AsRecord

function createType4AsRecord() returns Uuid | Error
Isolated Function

Returns a UUID of type 4 as a UUID record.

1uuid:Uuid uuid4 = check uuid:createType4AsRecord();

Return Type

(Uuid | Error)

UUID of type 4 as a UUID record or else a uuid:Error

createType4AsString

function createType4AsString() returns string
Isolated Function

Returns a UUID of type 4 as a string.

1string uuid4 = uuid:createType4AsString();

Return Type

(string)

UUID of type 4 as a string

createType5AsRecord

function createType5AsRecord(NamespaceUUID namespace, string name) returns Uuid | Error
Isolated Function

Returns a UUID of type 5 as a UUID record.

1uuid:Uuid uuid5 = check uuid:createType5AsRecord(uuid:NAME_SPACE_DNS, “ballerina.io”);

Parameters

  • namespace NamespaceUUID
  • String representation for a pre-defined namespace UUID

  • name string
  • A name within the namespace

Return Type

(Uuid | Error)

UUID of type 5 as a UUID record or else a uuid:Error

createType5AsString

function createType5AsString(NamespaceUUID namespace, string name) returns string | Error
Isolated Function

Returns a UUID of type 5 as a string.

1string uuid5 = check uuid:createType5AsString(uuid:NAME_SPACE_DNS, “ballerina.io”);

Parameters

  • namespace NamespaceUUID
  • String representation for a pre-defined namespace UUID

  • name string
  • A name within the namespace

Return Type

(string | Error)

UUID of type 5 as a string or else a uuid:Error

getVersion

function getVersion(string uuid) returns Version | Error
Isolated Function

Detect RFC version of a UUID. Returns an error if the UUID is invalid.

1uuid:Version v = check uuid:getVersion("4397465e-35f9-11eb-adc1-0242ac120002");

Parameters

  • uuid string
  • UUID string to be checked

Return Type

(Version | Error)

UUID version or else a uuid:Error

nilAsRecord

function nilAsRecord() returns Uuid
Isolated Function

Returns a nil UUID as a UUID record.

1uuid:Uuid nilUUID = uuid:nilAsRecord();

Return Type

(Uuid)

nil UUID

nilAsString

function nilAsString() returns string
Isolated Function

Returns a nil UUID as a string.

1string nilUUID = uuid:nilAsString();

Return Type

(string)

nil UUID

toBytes

function toBytes(string | Uuid uuid) returns byte[ ] | Error
Isolated Function

Converts to an array of bytes. Returns an error if the UUID is invalid.

1byte[] b = check uuid:toBytes(“6ec0bd7f-11c0-43da-975e-2aesass0b”);

Parameters

Return Type

(byte[ ] | Error)

UUID as bytes or else a uuid:Error

toRecord

function toRecord(string | byte[ ] uuid) returns Uuid | Error
Isolated Function

Converts to a UUID record. Returns an error if the array is invalid.

1uuid:Uuid r1 = check uuid:toRecord("4397465e-35f9-11eb-adc1-0242ac120002");
2uuid:Uuid r2 = check uuid:toRecord([10, 20, 30]);

Parameters

  • uuid string | byte[ ]
  • UUID to be converted

Return Type

(Uuid | Error)

UUID as record or else a uuid:Error

toString

function toString(byte[ ] | Uuid uuid) returns string | error
Isolated Function

Converts to a UUID string. Returns an error if the array is invalid.

1string s = check uuid:toString([5, 12, 16, 35]);

Parameters

  • uuid byte[ ] | Uuid
  • UUID to be converted

Return Type

(string | error)

UUID as string or else a uuid:Error

validate

function validate(string uuid) returns boolean
Isolated Function

Test a string to see if it is a valid UUID.

1boolean valid = uuid:validate("4397465e-35f9-11eb-adc1-0242ac120002");

Parameters

  • uuid string
  • UUID string to be validated

Return Type

(boolean)

true if a valied UUID, false if not