Parameter presence and type verification


_ <- fat.extra.Param

Error type is automatically imported with this import


This library introduces the Param type and the Using/UsingStrict utility for implicit parameter declaration.


Both Param and Using/UsingStrict constructors take two arguments:

  • _exp: Text: the parameter name to check in context.
  • _typ: Type: the expected type of the evaluated value.

Additionally Param accepts an optional argument:

Using has this flag set as false, and UsingStrict has it set as true


The Param type provides mechanisms for checking the presence and type of parameters in the execution context.

Prototype members

Name Signature Brief
get (): Any Retrieves the parameter if it matches the type

the get method throws KeyError if the parameter is not defined, and TypeError if the type does not match


_ <- fat.extra.Param
_ <- fat.type.Text  # the desired type must be loaded

currentUser = Param('userId', Text)


# Assuming userId is defined in the context and is a text,
# safely retrieve it's value from the current namespace
userId = currentUser.get


Apply Using/UsingStrict to suppress implicit parameter hints on method declarations for entries expected to be in scope.

alternatively, to suppress warnings about implicit parameters, name the implicit entry starting with an underscore (_)


_ <- fat.extra.Param
_ <- fat.type.Text

printUserIdFromContext = -> {
  Using('userId', Text)

if the implicit parameter is missing or mismatched, an error will be raised at runtime when the method is called

See also

results matching ""

    No results matching ""