A JavaScript library for defining and validating object schemas with a clean, intuitive syntax and JSON Schema serialization.
js-schema is a JavaScript library for declarative object validation. It allows developers to define object schemas using an intuitive syntax and validate data against those schemas, with support for serializing to and from JSON Schema format. It solves the problem of writing repetitive validation logic by providing a clean, pattern-based approach.
JavaScript developers who need runtime object validation in Node.js or browser environments, particularly those working with complex data structures or integrating with JSON Schema.
Developers choose js-schema for its readable schema definitions, flexible pattern system, and JSON Schema interoperability, which reduces boilerplate code compared to manual validation or more verbose validation libraries.
Simple and intuitive schema validator
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The syntax is intuitive, using patterns like { age: Number.min(0).max(5) } that make validation logic easy to write and understand, reducing boilerplate code.
Supports 10 basic rules including instanceof, regex, and deep equality, allowing for complex validations like object property matching and self-referencing schemas for recursive structures.
Returns specific error messages for each validation failure, such as 'number = 6 is bigger than required maximum = 5', which aids in debugging data issues.
Can serialize schemas to JSON Schema format and deserialize them back, facilitating integration with tools that use JSON Schema, though support is noted as incomplete.
The last release was in 2015 (version 1.0.1), meaning no updates for modern JavaScript features, potential unfixed bugs, and limited community support.
The README explicitly states that JSON Schema support is still incomplete, making it unreliable for projects requiring full compliance or advanced JSON Schema drafts.
Advanced features like regex property names in object patterns (e.g., 'colou?r') can be confusing and error-prone, requiring careful reading of documentation to avoid mistakes.