Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nuxodin/jema.js
JSON Schema handling / validator
https://github.com/nuxodin/jema.js
fast json-schema json-schema-validator v2020-12 validator
Last synced: about 1 month ago
JSON representation
JSON Schema handling / validator
- Host: GitHub
- URL: https://github.com/nuxodin/jema.js
- Owner: nuxodin
- License: mit
- Created: 2023-02-02T17:35:26.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-06T08:02:14.000Z (6 months ago)
- Last Synced: 2024-04-13T21:59:25.428Z (5 months ago)
- Topics: fast, json-schema, json-schema-validator, v2020-12, validator
- Language: JavaScript
- Homepage:
- Size: 114 KB
- Stars: 14
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jema.js
JSON Schema validator for ***deno*** and ***browsers***JSON Schema is the leading standard for validating and describing data. It is platform-independent and simplifies the automation of validation, documentation, and processing of data.
## Features
🚀 Performant
🕊️ Lightweight (< 4kb brotli)
🤝 Works in the Browser and deno (no node.js at the moment)
📦 No dependencies
🆗 JSONSchema draft-2020-12 (only this)## Basic ussage
```javascript
const schema = new Schema({
type: 'string',
minLength: 3,
pattern: '^[a-zA-Z]+$',
});
await schema.deref(); // Dereference remote schemasschema.validate('Li') // false
schema.validate('Liam') // true
schema.validate('Li-Am') // false
```## Install
```javascript
import {Schema} from 'https://cdn.jsdelivr.net/gh/nuxodin/[email protected]/schema.min.js';
```## Debugging
```javascript
// errors
const errors = schema.errors('L-')
for (const error of errors) {
console.log(error.message)
// "L-" does not match minLength:3
// "L-" does not match pattern:^[a-zA-Z]+$
}// schema validation
const schema = new Schema({
type: 'stringg',
});
await schema.schemaErrors();```
## Todo
- Better error messages (~~with schema location~~, conforming to the JSON Schema spec)
- Fix a few bugs in the test suite: [link](http://gcdn.li/nuxodin/jema.js/tests/test-suite.html) mainly
- "$dynamicRef"
- "$vocabulary"
- and some minor "format" errorsIf someone wants to help, please do so.
## About
- MIT License, Copyright (c) 2022 (like all repositories in this organization)
- Suggestions, ideas, finding bugs and making pull requests make us very happy. ♥