Registry / database / tobl-data-schema

tobl-data-schema

JSON →
library3.12.24jsnpmunverified

Shared data schema for TOBL projects, version 3.12.24. This package provides TypeScript types and runtime validation for data structures used across TOBL applications. It is published on npm and follows semantic versioning. The schema is designed to ensure consistency between backend (tobl-functions-ts) and frontend (tobl-web) projects. It includes Zod schemas for runtime validation and TypeScript types for static checking. The package is actively maintained with regular releases tied to schema changes.

npm install tobl-data-schema
INSTALL
IMPORT
SIG · TOBL-DATA-SCHEMA
T
tobl-data-schema
databasejavascriptv3.12.24
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

UserSchema
import { UserSchema } from 'tobl-data-schema'
import UserSchema from 'tobl-data-schema'
Named export, not default. This package uses named exports exclusively.
User
import type { User } from 'tobl-data-schema'
import { User } from 'tobl-data-schema'
Use type-only import for TypeScript types to avoid runtime overhead.
validateUser
import { validateUser } from 'tobl-data-schema'
const { validateUser } = require('tobl-data-schema')
ESM-only package; require() will fail. Use import syntax.

Shows how to import the schema and type, parse user data, and handle validation errors using Zod's safeParse.

import { UserSchema, User } from 'tobl-data-schema'; import { z } from 'zod'; const userData = { name: 'Alice', email: 'alice@example.com', age: 30 }; const result = UserSchema.safeParse(userData); if (result.success) { const user: User = result.data; console.log('Valid user:', user); } else { console.error('Validation errors:', result.error.issues); }
Debug
Known issues
breakingVersion 3.0.0 changed all schema exports to named exports. Default export removed.
fix
Change import { default as DataSchema } from 'tobl-data-schema' to import { UserSchema } from 'tobl-data-schema' or equivalent named export.
affects: >=3.0.0
gotchaTypeScript types are only available via type-only import. Importing as value will produce a runtime error.
fix
Use import type { User } from 'tobl-data-schema' instead of import { User } from 'tobl-data-schema'.
affects: >=1.0.0
deprecatedDeprecated export: `UserValidator` has been renamed to `validateUser` in v2.5.0.
fix
Replace `UserValidator` with `validateUser` in import and usage.
affects: >=2.5.0 <3.0.0
gotchaThe package is ESM-only. require() calls will fail with ERR_REQUIRE_ESM.
fix
Switch to ESM imports in your project, or use dynamic import() if you must use CommonJS.
affects: >=3.0.0
Errors
Common errors & fixes
ERR_MODULE_NOT_FOUND: Cannot find package 'tobl-data-schema' imported from ...
Package not installed or not in node_modules.
fix
Run `yarn add tobl-data-schema` or `npm install tobl-data-schema` to install the package.
TypeError: Cannot destructure property 'UserSchema' of ... as it is undefined.
Using CommonJS require() which is not supported in ESM-only package.
fix
Change `const { UserSchema } = require('tobl-data-schema')` to `import { UserSchema } from 'tobl-data-schema'`.
TS2590: Expression produces a union type that is too complex to represent.
Using `import { User } from 'tobl-data-schema'` as a value instead of a type-only import causes TypeScript to resolve the entire schema type.
fix
Use `import type { User } from 'tobl-data-schema'` instead.
Upgrade
Version history
3.12.24latest on npm
Audit
Dependencies
zodrequiredRuntime validation of data structures using Zod schemas
Agent activity
17 hits · last 30 days
node
14
Meta
1
OpenAI (training)
1
Resources
tobl-data-schema — npm install tobl-data-schema · libregistry