Skip to content

Esprima expressions

Sergej edited this page Apr 30, 2019 · 1 revision

Builder is making use of Esprima, high-performance ECMAScript parser.
This allows using expressions as property selectors.

For example

x => x.Prop1.Prop2

Above can be parsed into an expression tree that can be recursively inspected by the builder to produce a nested JSON Schema structure.

Property selection is not the only use case. The same technique is used for parsing binary expressions for building property value constraints.

For example:

x => x === 10

This is parsed as a binary expression which builder can convert to JSON schema constraints, setting minimum/maximum items in the array or limiting string length.

Clone this wiki locally