restriction

Returns the value restriction of a thing as type str or nil when the thing is not value restricted. A thing can be restricted when the thing is a property of a typed thing or by using the restrict(..) function (see the example).

This function does not generate a change.

Function

thing.restriction()

Arguments

None

Return value

Returns restriction of the thing or nil if not value restricted.

Example

Using restriction() on a non-restricted thing:

{}.restriction();

Return value in JSON format

null

Using restriction() on a restricted thing:

{}.restrict('str').restriction();

Return value in JSON format

"str"

Using restriction() on a another restricted thing:

// Create an example type
set_type('X', {onlyint: 'thing<int>'});

X{}.onlyint.restriction();

Return value in JSON format

"int"