Skip to content

Commit 4835a12

Browse files
committed
Add README
1 parent 3de558d commit 4835a12

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,92 @@
11
# JSON Schema (lite)
2+
3+
**_NOT FOR PRODUCTION USE_**
4+
5+
This is a minimal implementation of JSON Schema 2020-12 with a couple of the
6+
more complex features left out. This implementation exists solely to facilitate
7+
the qualification task for the JSON Schema GSoC project [Better JSON Schema
8+
Errors](https://github.com/json-schema-org/community/issues/870) project. Do not
9+
use it in production. It will not be maintained or supported.
10+
11+
## Qualification Task
12+
13+
There's no better way to get familiar with the JSON Schema output format than to
14+
implement it yourself. This implementation currently implements the Flag output
15+
format. Your task is to update it to support either the Basic or Detailed output
16+
formats. You must include `valid`, `absoluteKeywordLocation`, and
17+
`instanceLocation`. Because we aren't implementing the Verbose output format,
18+
you don't need to support `annotations`/`annotation`. You don't need to support
19+
`error` because we're going to ignore messages from the implementation anyway.
20+
`keywordLocation` is optional because I can't see any reason we'd use it. You
21+
must include tests to show that your implementation works including coverage for
22+
all implemented keywords.
23+
24+
To submit your qualification task, use `npm pack` and DM it to me. I will
25+
provide one and only one review for each candidate, so make sure you're ready
26+
when you submit. You can't fail the qualification task. As long as you submit
27+
something, I'll consider your application. However, I will strongly take into
28+
consideration the quality of your submission when evaluating applications.
29+
30+
This project uses ESLint. I encourage you to install an ESLint plugin in your
31+
editor to get feedback in real time. ESLint is also used for code style checks,
32+
but it doesn't check everything, so make an effort to match my code style when
33+
making changes.
34+
35+
There are three scripts you should make sure that you are passing before
36+
submitting.
37+
38+
- `npm test`
39+
- `npm run lint`
40+
- `npm run type-check`
41+
42+
I strongly encourage you to turn off your AI coding assistants for this
43+
exercise. They tend to generate very low quality code. Code that works is just
44+
the beginning. It also needs to be maintainable. Sloppy code hides bugs, is hard
45+
to maintain, and slows down progress in the long term. This may be throw away
46+
code that we're never going to build on later, but remember that part of the
47+
goal of this task is to demonstrate your ability to write quality code for a
48+
project that will need to evolve and be maintained over the several next years.
49+
50+
## About the Implementation
51+
52+
Unsupported features and keywords
53+
- Embedded schemas
54+
- `$anchor`
55+
- `$dynamicRef`/`$dynamicAnchor`
56+
- `unevaluatedProperties`/`unevaluatedItems`
57+
- `format` assertion
58+
- Annotations
59+
- Custom dialect/vocabularies/keywords
60+
- Older dialects
61+
- Retrieving files from the file system or the web
62+
63+
### API
64+
65+
* `validate(schema: Json, instance: Json) => Output`
66+
* `registerSchema(schema: Json, uri: string) => void`
67+
68+
The `Json` type represents any JavaScript value that is compatible with JSON.
69+
70+
The `Output` type represents the Flag output format. It includes the `valid`
71+
property, but no `errors`.
72+
73+
### Example Usage
74+
75+
```javascript
76+
import { validate } from "../src/index.js";
77+
78+
/**
79+
* @import { Json } from "./src/jsonast.d.ts"
80+
*/
81+
82+
/** @type Json */
83+
const schema = {
84+
$ref: "#/$defs/a",
85+
$defs: {
86+
a: { type: "number" }
87+
}
88+
};
89+
const instance = true;
90+
const output = validate(schema, instance);
91+
console.log("valid", output.valid);
92+
```

0 commit comments

Comments
 (0)