Skip to content
GitHub

Guides

Use cases

When to reach for each function, with real screens in mind; every result shown is computed by the library.

Each case shows the TypeScript to write and, in the comments, what the library returns for it. The results are computed when this page is built, by the same code you install. The PHP calls have the same names on value objects (PhoneNumber::safeParse(), Ariary::spellText(), …).

Check a +261 number as it is typed, show the reason when it is refused, and store it in E.164 with its operator.

const result = safeParsePhone(input);
if (!result.success) return showError(result.error.code);
save(result.data.e164, result.data.operator);
// → '031 12 345 67' → UNKNOWN_OPERATOR
// → '034 12 345 67' → +261341234567, Yas Madagascar

Write the amount in words, as a cheque or a contract needs it.

spellAriary(1250000);
// → dimy alina sy roa hetsy sy iray tapitrisa ariary

Read an amount written the Malagasy way (Ar 1.500,50), then show it the way your screen needs.

const amount: number = parseAriary('Ar 1.500,50');
formatAriary(amount, { symbolPosition: 'after' });
// → 1500.5
// → 1 500,5 Ar

Show and convert old Malagasy francs (FMG) to ariary, exactly in decimal.

formatFmg(7500);
fmgToAriary(7500);
// → Fmg 7 500
// → 1500 ariary

One name per power of ten, for texts that ask for the traditional system.

spell(30_000_000);
spell(30_000_000, { system: 'traditional' });
// → telopolo tapitrisa
// → telo safatsiroa

Malagasy month and weekday names, in every date style.

formatDate('2026-06-26', 'full');
monthName(6, 'abbreviated');
// → Zoma 26 Jona 2026
// → Jon