New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gulp-data-validate

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-data-validate

Validate data files against their respective JSON schemas

0.3.1
latest
Source
npm
Version published
Maintainers
1
Created
Source

gulp-data-validate

latest version on npm npm downloads a month required node version package license

Validate data files against their respective JSON schemas

Uses ajv, json-schema-ref-parser and import-fresh under the hood.

How

Have a *.data.js and a *.schema.json file for your module on the same level. Pass in the data file to the plugin, and, boom: See whether it's valid. If it's not, it'll log what's to be done.

yarn add gulp-data-validate --dev
v modules
  v my-module
    > my-module.hbs
    > my-module.scss
    > my-module.js
    > my-module.data.js
    > my-module.schema.json
  > my-other-module
  > another-one
  > best-module
const { src } = require('gulp');
const validate = require('gulp-data-validate');

module.exports.schema = src('modules/**/*.data.js').pipe(validate());

Options

You can pass in an object containing three keys: schemaSuffix, failOnError and ignorePrefix. With those three, you can adapt to your naming scheme and control whether the build should fail when the data files aren't valid.

const defaultOptions = {
  schemaSuffix: '.schema.json',
  failOnError: false,
  ignorePrefix: '_'
};

If your schemas are just named *.json, you want to skip schema validation for files beginning with _ and you want the build to fail on error (nice for CI-purposes), your folder structure and config would look like this:

v modules
  v my-module
    > my-module.hbs
    > my-module.scss
    > my-module.js
    > my-module.data.js
    > my-module.json
    v partials
      _my-partial.hbs
      _my-partial.scss
      _my-partial.data.js
  > my-other-module
  > another-one
  > best-module
const { src } = require('gulp');
const validate = require('gulp-data-validate');

module.exports.schema = src('modules/**/*.data.js').pipe(validate({
  schemaSuffix: '.json',
  failOnError: true,
  ignorePrefix: '_'
}));

License

MIT

Keywords

gulpplugin

FAQs

Package last updated on 12 Nov 2020

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