RumbleDB/rumble

Optional external variables with specific type

jsommr opened this issue · 0 comments

I'm trying to do this:

declare variable $optional as string external := null;
declare variable $mandatory as string external;

Where $mandatory is required --variable:mandatory must-be-set, but $optional defaults to null. An easy fix would be to instead use an empty string as default value, but if an empty string is a valid value, that won't work.

One could also declare the variable without a type and have RumbleDB infer it at runtime, but being explicit about the type would make it possible to auto generate documentation based on static code analysis: $optional is a string, and it's optional, so null is used if it's not set.

If there's no good way to do this with RumbleDB at the moment, It would be highly appreciated if someone could offer a few pointers on how I could implement this.

Update:

declare variable $optional as string? external := ();
if ($optional) then
  $optional
else
  "()"

Guess this is it!