schema-typed is a data modeling and validation library for JavaScript and TypeScript, now at v2.4.2 (stable). It provides a fluent API to define schemas with typed validators (StringType, NumberType, ArrayType, ObjectType, BooleanType, DateType) and supports synchronous and asynchronous validation, nested object validation, field dependencies, custom rules, and schema composition via SchemaModel.combine(). Key differentiators: strong TypeScript support with full type inference for validated data, a builder pattern for readable schemas, and detailed error messages. It is maintained and widely used in the rsuite ecosystem but can be used standalone.
npm install schema-typedNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a user schema with required string and number fields, then validates sample data showing error messages.
Use `isRequiredOrEmpty(errorMessage)` instead of `isRequired` if you want to allow empty but still validate other rules.
Use a custom rule with `addRule` for nested field comparisons.
Check all fields: `Object.values(result).every(f => !f.hasError)`.
Use `when` sparingly and consider caching schemas if needed.
Use `StringType().pattern(...)` on a stringified version of the number.
Use `const model = SchemaModel({...})` without `new`.Ensure the field exists in the schema and data. Use optional chaining: `result.fieldName?.hasError`.
Parse input to number before validation: `age: NumberType().isInteger('Must be integer').check(Number(value))`.No dependency data recorded yet.