A simple, typescript-first schema validation tool.
Project details
Jet-Schema offers a straightforward, TypeScript-first approach to schema validation, allowing you to implement your custom validator functions easily. With a lightweight footprint and zero dependencies, it empowers you to validate object properties without being tied to any specific library, ensuring flexibility and control.
jet-schema is a straightforward and efficient TypeScript-first schema validation tool designed to improve your development workflow by allowing you to utilize your own custom validator functions. This zero-dependency library prioritizes simplicity and flexibility, making it easier to validate object properties without the need to consult extensive documentation each time you create or modify a validation function.
.new, .test, and .parse functions with every new schema you create, simplifying the coding process.Date objects for easy manipulation.import schema from 'utils/schema';
import { isString, isNumber } from 'utils/validators';
interface IUser {
id: number;
name: string;
}
const User = schema<IUser>({
id: isNumber,
name: isString,
});
User.new({ id: 5, name: 'joe' }) // => { id: 5, name: 'joe' }
User.test('asdf') // => false
User.pick('name').test('john') // => true
User.parse('something') // => Error
ts-node.If you're looking for a robust, TypeScript-friendly library that empowers you to harness your custom validation logic while keeping your application lightweight and efficient, jet-schema could be the perfect choice for you. Whether developing in TypeScript or JavaScript, integrate this tool into your project and transform the way you handle schema validations.
Comments
8Very cool project, starred.
This is cool! Impressive that it all fits into 5kb. One thing to consider: zod has kind of become the go-to in the TS ecosystem. A lot of sdks like openai work with zod objects directly, and tools like
zod-to-json-schemamake it easy to keep zod schemas as the source of truth.For jet-schema to really catch on, it might help to have similar converters. At the very least, something like a
jet-schema-to-zodutility (either built-in or as a separate package) could make it easier for people to migrate or integrate into existing workflows.