@coli.codes/schema
v0.0.34
Published
This lib enables programmers to develop app that requires data schema declaration from user.
Downloads
17
Readme
A progomatic Schema designer
This lib enables programmers to develop app that requires data schema declaration from user.
It follows JSON Schema standard & It's pojo typings with extra pre-defined real-world type declarations - for example, text and image
This is a package to extend coli programatically. You might experience some "why does it not work like others?" moments.
Usage
// new schema factory for ease of use
// plain JsonObj as nested type
interface LatLng {
lat: number
lng: number
}
// some custom built reusable type definition
const ThisOrThat = new SchemaFactory({} | {});
const myReactPropsSchemaFactory = new SchemaFactory({
name: string,
location: LatLng
});
// retrieve extract JSON formatted schema definition
const def = myReactPropsSchemaFactory.definition;
// validating input data
const __someDynamicInputData = { ... }
const isInputDataValid = myReactPropsSchemaFactory.validate(__someDynamicInputData)
Create factory from other sources
// input a example data (json)
SchemaFactory.fromExample();
// input a schema definition string (schema json)
SchemaFactory.fromDefinition();
Used by
References
IDK (Developer's Idea note - something experimental)
- extending a json schema? - https://stackoverflow.com/a/41020586/5463235