Registry / devops / farrow-schema

farrow-schema

JSON →
library2.3.3jsnpmunverified

A powerful and extensible schema builder for TypeScript, part of the Farrow web framework ecosystem. Current stable version is 2.3.3. It provides type-safe runtime validation with a composable schema API, allowing developers to define and validate data structures with full TypeScript inference. Key differentiators include deep type inference from schemas, support for complex nested schemas, and integration with Farrow's HTTP pipeline for end-to-end type safety. Release cadence is irregular, tied to Farrow framework updates. Compared to Zod or io-ts, farrow-schema is designed specifically for Farrow's module-oriented architecture.

npm install farrow-schema
INSTALL
IMPORT
SIG · FARROW-SCHEMA
F
farrow-schema
devopsjavascriptv2.3.3
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 'farrow-schema'
import Schema from 'farrow-schema'
Schema is a named export, not default. Common mistake.
Type
import { Type } from 'farrow-schema'
const { Type } = require('farrow-schema')
CJS require is supported but ESM is recommended.
validate
import { validate } from 'farrow-schema'
validate is a helper function to check data against a schema.

Schema definition and validation using farrow-schema with TypeScript type inference.

import { Schema, Type, validate } from 'farrow-schema'; const UserSchema = Schema.object({ id: Schema.number(), name: Schema.string(), email: Schema.string().pattern(/^[^@]+@[^@]+$/), age: Schema.number().optional() }); type User = Type<typeof UserSchema>; const userData = { id: 1, name: 'Alice', email: 'alice@example.com' }; const result = validate(UserSchema, userData); if (result.ok) { const user: User = result.value; console.log('Valid user:', user); } else { console.error('Validation errors:', result.errors); }
Debug
Known issues
breakingIn v2.0, Schema.object() changed from accepting a plain object to requiring Schema.object({...}).
fix
Update to use Schema.object() wrapper: Schema.object({ field: ... }) instead of plain object.
affects: >=1.x <2.0
gotchaType inference only works with TypeScript >=4.3; earlier versions may not infer correctly.
fix
Upgrade TypeScript to >=4.3 or use explicit type annotations.
affects: >=2.0
gotchaSchema is a named export, not default; many users mistakenly try default import.
fix
Use import { Schema } from 'farrow-schema'.
affects: >=1.0
deprecatedSchema.any() is deprecated in v2.0; use Schema.unknown() instead.
fix
Replace any with unknown in schema definitions.
affects: >=2.0
breakingIn v2.0, validate() returns { ok, value } instead of { success, data }.
fix
Check for ok property instead of success, and use value instead of data.
affects: >=1.x <2.0
Errors
Common errors & fixes
TypeError: (0 , farrow_schema_1.Schema) is not a function
Default import used instead of named import.
fix
Change import to: import { Schema } from 'farrow-schema'
TS2345: Type '{}' is not assignable to type '...'
Incompatible TypeScript version (<4.3) or missing schema wrapper.
fix
Upgrade TypeScript or wrap object definition with Schema.object().
Property 'ok' does not exist on type '{ success: boolean; data: any; errors: any[]; }'
Using old validate() return shape from v1.x.
fix
Check for ok and value; upgrade to v2.x.
Error: Unknown schema type: any
Using deprecated Schema.any() in v2.x.
fix
Replace with Schema.unknown().
Upgrade
Version history
2.3.3latest on npm
Audit
Dependencies
typescriptoptionalRequired for type inference; schemas rely on TypeScript >=4.3
Agent activity
2 hits · last 30 days
node
2
Resources
farrow-schema — npm install farrow-schema · libregistry