Process serialized conditional logic for dynamic form field permissions and validation
npm install form-metadata-2Install via NPM:
``bash`
npm install --save form-metadata
Import the module:
`js`
// ES2015 import
import { processFields, evaluateCondition, prepareSubmission } from 'form-metadata'
// CommonJS
const { processFields, evaluateCondition, prepareSubmission } = require('form-metadata')
To run tests:
`bash`
npm test
Expects a jsonPaths object mapping field key strings to JSON paths arrays.
Returns an object with two properties:
* fields - a flat tree with your fields' initial state, mirroring the structure of the jsonPaths map you provided.fieldChangeEffects
* - a tree of conditions organized by their dependencies.
Evaluate a serialized condition. The second argument should have the same structure as those fields returned by processFields.
Takes a tree of fields data (structured like the fields object returned from processFields()) and transforms it back into the same structure as jsonPaths`. This way, you can send your JSON back to the server in the same format you received it..