Sha256: 044010d821efb5d9d3c2f1425ac30fe4edf0cf84a7fdedede0cc72dde50d0e17

Contents?: true

Size: 842 Bytes

Versions: 7

Compression:

Stored size: 842 Bytes

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = validate;
exports.validateField = validateField;
exports.validateChild = validateChild;

var _definitions = require("../definitions");

function validate(node, key, val) {
  if (!node) return;
  const fields = _definitions.NODE_FIELDS[node.type];
  if (!fields) return;
  const field = fields[key];
  validateField(node, key, val, field);
  validateChild(node, key, val);
}

function validateField(node, key, val, field) {
  if (!(field != null && field.validate)) return;
  if (field.optional && val == null) return;
  field.validate(node, key, val);
}

function validateChild(node, key, val) {
  if (val == null) return;
  const validate = _definitions.NODE_PARENT_VALIDATIONS[val.type];
  if (!validate) return;
  validate(node, key, val);
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
disco_app-0.16.1 test/dummy/node_modules/@babel/types/lib/validators/validate.js
disco_app-0.15.2 test/dummy/node_modules/@babel/types/lib/validators/validate.js
disco_app-0.18.4 test/dummy/node_modules/@babel/types/lib/validators/validate.js
disco_app-0.18.1 test/dummy/node_modules/@babel/types/lib/validators/validate.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/@babel/types/lib/validators/validate.js
disco_app-0.14.0 test/dummy/node_modules/@babel/types/lib/validators/validate.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/@babel/types/lib/validators/validate.js