https://github.com/gridaco/schema
Visual data IDE & Modules
https://github.com/gridaco/schema
Last synced: 9 months ago
JSON representation
Visual data IDE & Modules
- Host: GitHub
- URL: https://github.com/gridaco/schema
- Owner: gridaco
- License: mit
- Created: 2020-09-23T15:45:14.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2023-02-11T16:44:12.000Z (over 3 years ago)
- Last Synced: 2024-05-23T00:19:11.096Z (about 2 years ago)
- Language: Dart
- Homepage:
- Size: 1.99 MB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# schema
schema engine & mock data provider
## Editor
## Usage
```bash
yarn add @grida/schema
```
```ts
import { Schema } from "@grida/schema";
const schema = new Schema({
type: "object",
properties: {
name: {
type: "string",
},
age: {
type: "number",
},
},
});
schema.mock(); // { name: 'string', age: 0 }
schema.validate({ name: "string", age: 0 }); // true
```
```tsx
// React Renderer
import { Schema } from "@grida/schema";
import SchemaView, { SchemaChangeEvent } from "@grida/schema-react";
const schema = new Schema({
type: "object",
properties: {
name: {
type: "string",
},
age: {
type: "number",
required: true,
label: "Age",
description: "Age of the person",
},
},
});
function Form() {
const onChange = (e: SchemaChangeEvent, s: Schema, o: object) => {
// schema is updated
};
return ;
}
```
## Related projects
- [CoLI](https://github.com/gridaco/coli)