Skip to content
GitHub

Spec

One spec, every language

Every mdg-utils package implements the same specification — data with official sources and shared test vectors — so a function gives the same answer in JavaScript, PHP and every future port.

The spec repository holds, for each module, the rules in plain words, the data with an official source and the date it was checked, and the test vectors: inputs with the exact output or error code every port must produce.

mdg-utils-spec data, rules, Public API tables, test vectors
├─ mdg-utils-js includes the spec, generates its tables, runs every vector
└─ mdg-utils-php includes the spec, generates its tables, runs every vector

Tests are the contract

A port is complete when it passes every vector and provides every function in each module’s Public API table.

Same error codes

INVALID_TYPE, OUT_OF_RANGE, INVALID_FORMAT and UNKNOWN_OPERATOR mean the same thing in every language.

Three ways to parse

parse throws, safeParse returns the value or the error code, tryParse returns the value or nothing.

Sources for every value

No source, no merge: data comes from laws, regulators or recognised dictionaries.