@revisium/formula 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,24 +62,6 @@ inferFormulaType('price * quantity', { price: 'number', quantity: 'number' });
|
|
|
62
62
|
inferFormulaType('price > 100');
|
|
63
63
|
// 'boolean'
|
|
64
64
|
|
|
65
|
-
// Schema validation
|
|
66
|
-
import { validateFormulaAgainstSchema } from '@revisium/formula';
|
|
67
|
-
|
|
68
|
-
const schema = {
|
|
69
|
-
type: 'object',
|
|
70
|
-
properties: {
|
|
71
|
-
price: { type: 'number' },
|
|
72
|
-
quantity: { type: 'number' },
|
|
73
|
-
total: { type: 'number', 'x-formula': { version: 1, expression: 'price * quantity' } }
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
validateFormulaAgainstSchema('price * quantity', 'total', schema);
|
|
78
|
-
// null (valid)
|
|
79
|
-
|
|
80
|
-
validateFormulaAgainstSchema('price > 100', 'total', schema);
|
|
81
|
-
// { field: 'total', error: "Type mismatch: formula returns 'boolean' but field expects 'number'" }
|
|
82
|
-
|
|
83
65
|
// Array item formulas with path resolution
|
|
84
66
|
import { evaluateWithContext } from '@revisium/formula';
|
|
85
67
|
|
|
@@ -127,14 +109,6 @@ evaluateWithContext('price * (1 - ../discount)', {
|
|
|
127
109
|
| `detectCircularDependencies` | Detect circular dependencies in graph |
|
|
128
110
|
| `getTopologicalOrder` | Get evaluation order for nodes |
|
|
129
111
|
|
|
130
|
-
### Schema Validation
|
|
131
|
-
|
|
132
|
-
| Function | Description |
|
|
133
|
-
|----------|-------------|
|
|
134
|
-
| `extractSchemaFormulas` | Extract formulas from JSON Schema |
|
|
135
|
-
| `validateFormulaAgainstSchema` | Validate single formula against schema |
|
|
136
|
-
| `validateSchemaFormulas` | Validate all formulas in schema |
|
|
137
|
-
|
|
138
112
|
## Path Syntax
|
|
139
113
|
|
|
140
114
|
| Syntax | Description | Example |
|