@statesync/core / isCanonicalRevision
Function: isCanonicalRevision()
ts
function isCanonicalRevision(value): value is Revision;Defined in: revision.ts:57
Checks whether a value is a valid canonical revision string.
A canonical revision must:
- Be a string
- Match the pattern
^(0|[1-9][0-9]*)$(no leading zeros except bare "0") - Represent a value within the unsigned 64-bit integer range (0 to 2^64 - 1)
This is a TypeScript type guard that narrows the input to Revision.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to validate. Can be of any type. |
Returns
value is Revision
true if the value is a valid canonical revision string, false otherwise.
Example
ts
import { isCanonicalRevision } from '@statesync/core';
isCanonicalRevision('42'); // true
isCanonicalRevision('0'); // true
isCanonicalRevision('007'); // false (leading zeros)
isCanonicalRevision(-1); // false (not a string)
isCanonicalRevision('abc'); // false (non-numeric)