Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chnapy/tabbouleh-sample-ajv
Tabbouleh sample with AJV validator
https://github.com/chnapy/tabbouleh-sample-ajv
Last synced: 10 days ago
JSON representation
Tabbouleh sample with AJV validator
- Host: GitHub
- URL: https://github.com/chnapy/tabbouleh-sample-ajv
- Owner: Chnapy
- License: mit
- Created: 2019-08-27T21:42:44.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-31T16:53:39.000Z (over 4 years ago)
- Last Synced: 2024-10-19T12:16:11.258Z (3 months ago)
- Language: TypeScript
- Homepage: https://chnapy.github.io/tabbouleh-sample-ajv
- Size: 673 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tabbouleh sample with AJV validator
Basic sample which combine [tabbouleh](https://github.com/Chnapy/tabbouleh) (JSON Schema generation) with [ajv](https://github.com/epoberezkin/ajv) (data validation).
[**__Preview here__**](https://chnapy.github.io/tabbouleh-sample-ajv)
# Getting started
```
npm install
``````
npm start
```# How it works
Simplified steps:
```typescript
// generate the UserData schema
const schema = Tabbouleh.generateJSONSchema(UserData);// instantiate AJV & compile the schema
const ajv = new Ajv();
const validate = ajv.compile(schema);// get the data from input or anything else...
// validate data with AJV
const valid = validate(data) // booleanif(!valid) {
// there is errors
console.log(validate.errors);
}
```