indicative-parser
Advanced tools
Comparing version 7.1.1 to 7.1.2
{ | ||
"name": "indicative-parser", | ||
"version": "7.1.1", | ||
"version": "7.1.2", | ||
"description": "Schema parser for Indicative", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -24,2 +24,3 @@ <div align="center"> | ||
- [Usage](#usage) | ||
- [Typed schema](#typed-schema) | ||
- [Maintainers](#maintainers) | ||
@@ -41,3 +42,3 @@ | ||
Instead, we pre-compile the schema (later cache it) and generate a tree, which is easier to reason about and then generated optimized functions from the parsed tree. | ||
Instead, we parse the schema into a tree. The tree is later converted to an array of top level functions that are highly optimized for performance. | ||
@@ -103,2 +104,17 @@ ## Usage | ||
## Typed schema | ||
The parser also allows creating declarative schema that has static type information along with the parsed tree. The type information is really helpful for Typescript projects. | ||
```ts | ||
import { rulesParser, t } from 'indicative-parser' | ||
rulesParser(t.schema({ | ||
username: t.string(), | ||
account: t.object().members({ | ||
type: t.string(validations.in(['email', 'social'])) | ||
}) | ||
})) | ||
``` | ||
## Maintainers | ||
@@ -105,0 +121,0 @@ [Harminder virk](https://github.com/thetutlage) |
26529
130