Registry / testing / schemastery

schemastery

JSON →
library3.18.0jsnpmunverified

Schemastery is a TypeScript-driven schema validation library (v3.18.0, actively maintained, monthly releases). It defines schemas using TypeScript inference rather than runtime builders, offering type-safe validation and transformation. Compared to Zod or Yup, it emphasizes integration with TypeScript generics for maximum type inference and a lightweight footprint. It supports nested objects, arrays, unions, and custom types with full type narrowing and error reporting.

npm install schemastery
INSTALL
IMPORT
SIG · SCHEMASTERY
S
schemastery
testingjavascriptv3.18.0
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.

Schema
import { Schema } from 'schemastery'
const Schema = require('schemastery').Schema
Use named import for Schema class; ESM-only since v3.
s
import { s } from 'schemastery'
import * as schemastery from 'schemastery' then schemastery.s
Direct named import for the schema builder.
string
import { string } from 'schemastery'
import { Schema } from 'schemastery'; const string = Schema.string
Preferred import for type-specific schema helpers.

Defines a user schema with string and number, validates data, and infers the TypeScript type.

import { s, string, number, object } from 'schemastery' const userSchema = object({ name: string().required(), age: number().min(0), }) // Validate const data = { name: 'Alice', age: 30 } const result = userSchema.validate(data) if (!result.error) { console.log(result.value) // { name: 'Alice', age: 30 } } // Type inference type User = typeof userSchema.type // { name: string, age: number }
Debug
Known issues
breakingValidation errors changed from returning booleans to returning error objects in v3.
fix
Check result.error instead of result === true.
affects: >=3.0.0
breakingImport paths changed in v3; 'schemastery' package no longer exports default.
fix
Use named imports: import { s, Schema } from 'schemastery'.
affects: >=3.0.0
deprecatedSchema.string() is deprecated in favor of string() helper.
fix
Use import { string } from 'schemastery' instead of Schema.string().
affects: >=3.0.0
gotchaSchema type inference may fail on intersections; use z.union() for complex unions.
fix
Use union helper: import { union } from 'schemastery'.
affects: >=3.0.0
Errors
Common errors & fixes
TypeError: schemastery_1.s is not a function
Using default import or wildcard import incorrectly.
fix
Use named import: import { s } from 'schemastery'
Property 'validate' does not exist on type 'Schema<...>'
Importing older version or wrong export.
fix
Ensure schemastery v3 installed and use correct schema from object() result.
Schema requires 'name' but got undefined
Missing required field in data during validation.
fix
Add the required field or mark it as optional with .optional()
Cannot find module 'schemastery' or its corresponding type declarations.
Missing TypeScript types or not installed.
fix
Install schemastery via npm (includes types).
Upgrade
Version history
3.18.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
4
Amazon
1
Resources
schemastery — npm install schemastery · libregistry