restriction

Returns the dictionary key and value restrictions as a list of two strings. The first element represents the key restriction, and the second represents the value restriction. A dict can only be restricted when defined as a property of a typed thing (see the example).

This function does not generate a change.

Function

dict.restriction()

Arguments

None

Return value

Returns a list containing two strings representing the key and value type restrictions (e.g., ["uuid", "T"] for keys of type uuid and values of type T). If no restriction is set, ["any", "any"] is returned.

Example

Using restriction() on a non-restricted dict:

dict().restriction();

Return value in JSON format

["any", "any"]

Using restriction() on a restricted dict:

// Create an example type
set_type('Example', {
    lookup: 'dict<uuid:str>',
});

Example{}.lookup.restriction();

Return value in JSON format

["uuid", "str"]