Skip to content
Arthur van de Vondervoort edited this page Jan 18, 2025 · 2 revisions

Use IsNullGuid() to check for empty GUID values.

This rule ensures that GUID comparisons are performed safely by enforcing the use of the IsNullGuid() method instead of direct comparisons. Directly comparing a GUID to an empty string ('') will cause a runtime error because '' is not a valid GUID format.

When a GUID is compared to a string-like type, the string is parsed into a GUID behind the scenes. If the string cannot be parsed into a valid GUID, a runtime exception is thrown.

Example

procedure MyProcedure()
var
    MyGuid: Guid;
begin
    if MyGuid = '' then; // Use 'IsNullGuid(MyGuid)' method instead of comparing the Guid 'MyGuid' with '', as this will result in a runtime error.
end;

procedure MyProcedure()
var
    MyGuid: Guid;
begin
    if IsNullGuid(MyGuid) then;
end;

Read more:

Clone this wiki locally