Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

enketo-validate

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enketo-validate

An XForm validator around Enketo's form engine

  • 1.7.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
232
increased by231.43%
Maintainers
1
Weekly downloads
 
Created
Source

Enketo Validate npm version Build Status Dependency Status devDependency Status

Validate ODK XForms using Enketo's form engine

This app can be used:

  1. via the command-line, e.g. in a non-javascript form builder such as pyxform.
  2. as a nodeJS module to be used in your own javascript application

Live demo web application (meant for testing purposes only) that uses Enketo Validate (and ODK Validate) as a module: validate.enketo.org (source code)

Prerequisites

  1. install nodeJS 8+
  2. install build tools for native modules with apt-get install build-essential

Via Command-line

Command-line Install

To make the enketo-validate command available from any folder on your machine.

$ npm install -g --production enketo-validate`

Alternatively, you can clone the repo and run npm install --production. This will make the ./validate command available from within the clone folder. Running npm link makes the enketo-validate command available from any folder on your machine.

Command-line Use
$ enketo-validate path/to/form.xml

Errors are returned to stderr and warnings to stdout. If there is no stderr output the form is valid.

Command-line Help
$ enketo-validate --help
Command-line update
  1. npm install -g --production enketo-validate

As NodeJS module

Module installation
npm install enketo-validate --save
Module Use
const validator = require('enketo-validate');

// Options:
// debug: [boolean] outputs unadulterated errors instead of cleaned ones
// oc: [boolean] runs the validator in a special OpenClinica mode
const options = {}; 

// Read the xform as string
const result = validator.validate( xformStr, options );

// The result has the following format:
// {
//      warnings: [ 'a warning', 'another warning'],
//      errors: ['an error', 'another error'],
//      version: "0.0.0"
// }
// if errors.length is 0, the form passed validation

How it works

In it's current iteration, the validator does the following:

  • It checks whether the XForm is a valid XML document.
  • It performs some basic ODK XForm structure checks.
  • It checks if each bind nodeset exists in the primary instance.
  • It checks if appearance values are supported for that type of question.
  • It checks for each <bind> whether the relevant, constraint, calculate, and required expressions are supported and valid* XPath.

* Note, that /path/to/nonexisting/node is perfectly valid XPath.

Funding

The development of this application was funded by OpenClinica.

License

See the license document for this application's license.

Change log

See change log

Keywords

FAQs

Package last updated on 02 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc