@mocanvas/editor · function

idValidator

declare function idValidator<Id extends string>(typeName: string): Validator<Id>

A validator for ids of the record type named by typeName.

``ts const widgetIdValidator = idValidator<WidgetId>("widget") ``

It checks the typeName: prefix and that something follows it — the two things that make an id well-formed. Whether the record actually exists is a question for the store, not for a validator.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.