Guides
Create a data type
Use cases define input/output using specific data types.
Intro
A data type is a class that extends the TBase
class directly or indirectly.
libmodulor
provides data types that are commonly used.
But some apps need specific data types.
Example
As an example, defining an ISIN as a string
is too approximative.
Indeed, it has a specific length, format, etc.
It defines two things that need to be exported :
- A type (e.g.
ISIN
that specifies the data type with a TypeScript type) - A class (e.g.
TISIN
that specifies how the data type behaves)
libmodulor
provides base data types that you can extend.
i18n
In the example above we've defined a format
for the ISIN.
When the end user inputs an invalid ISIN, it will trigger an error with the following key: validation_format_ISIN
.
This key can be translated in the app's i18n
. Check Translate an app for more details.