mirror of
https://github.com/nestriness/nestri.git
synced 2026-09-19 17:25:19 +03:00
fix(core): document an id that is actually a valid id
The example generator emitted twenty-five payload characters where an id has twenty-six, so every documented id was twenty-nine characters — one short of the width the column holds and, since last commit, one short of what the schema publishing it will accept. Nothing caught it because an example is never parsed: it is copied into documentation and read by people. The width now comes from the generator's own constant instead of being typed out, in the two places that had counted it by hand. Counting twenty-six of anything by eye is a thing people get right once and never re-check. A test pins the three together — a generated id, the schema for one, and the documented example must all agree, for every prefix. It fails on the off-by-one that prompted this, and on a prefix without its separator, which would otherwise read as an id of that type because it starts with the same three letters.
This commit is contained in:
@@ -47,7 +47,14 @@ export namespace Identifier {
|
||||
.length(prefixes[prefix].length + 1 + LENGTH);
|
||||
}
|
||||
|
||||
const LENGTH = 26;
|
||||
/**
|
||||
* How many characters follow the prefix and separator.
|
||||
*
|
||||
* Exported because three things have to agree on it and two of them are
|
||||
* not the generator: the column is fixed-width, {@link schema} refuses
|
||||
* anything else, and the documented examples have to be values that pass.
|
||||
*/
|
||||
export const LENGTH = 26;
|
||||
|
||||
let lastTimestamp = 0;
|
||||
let counter = 0;
|
||||
|
||||
Reference in New Issue
Block a user