World Conquest Chronicles

World Conquest Chronicles

luatypechecks, v1.0.0

The library that implements various type checks in order to simulate static typing in the Lua language.

Major version. Implemented checks for base types, including the ability to check table key types and table value types, as well as checks for classes created by library middleclass.

Note that this library isn't designed to validate input data, but only to simulate static typing for function parameters.

Disclaimer: this library was written directly on an Android smartphone with the QLua IDE.

Features

  • checks:
    • checks.is_boolean(value);
    • checks.is_number(value):
      • checks.is_integer(value);
    • checks.is_string(value);
    • checks.is_function(value):
      • checks.is_callable(value);
    • checks.is_table(value[, key_checker[, value_checker[, deep_checks_mode="with_deep_checks"]]]):
      • checks.is_sequence(value[, value_checker[, deep_checks_mode="with_deep_checks"]]);
    • checks.is_enumeration(value, enumeration);
    • checks.is_instance(value, class);
  • for each check:
    • there is a variant that allows the value nilchecks.is_*_or_nil(value, ...);
    • if the check accepts additional parameters, there is a constructor that creates a closure with these parameters (i.e., performs currying) — checks.make_*_checker(...);
  • optimization:
    • it's possible to disable checking of table key types and table value types:
      • individually for a particular check;
      • globally for the whole package.

Installation

Clone this repository:

$ git clone https://github.com/thewizardplusplus/luatypechecks.git
$ cd luatypechecks

Install the library with the LuaRocks tool:

$ luarocks make

Repository

Link: https://github.com/thewizardplusplus/luatypechecks/tree/v1.0.0.

Content: code.

License: MIT.