function validateShape(shape, schema) { var validationErrors = this.js.validate(shape, schema); if (validationErrors.length > 0) { var fields = normalize(validationErrors).fields; var errors = buildErrors(fields); var err = ValidationError(errors); err.attribute = errors[0].attribute; err.original = validationErrors; return err; } return null; }
function onverify(err, errors) { if (err) { return callback(err); } if (errors.length === 0) { return onnpm(null, npm); } var error = ValidationError(errors); var invalid = find(errors, function (error) { return error.type === 'invalid.git.version'; }); if (invalid) { var msg = 'Problems were encountered\n' + 'Please correct and try again\n' + 'invalid: {name}@{actual} {dirname}/node_modules/{name}'; error.message = template(msg, invalid); } var types = errors.reduce(function (acc, e) { if (acc.indexOf(e.type) === -1) { acc.push(e.type); } return acc; }, []); if (opts.warnOnNotSemver && types.length === 1 && types[0] === 'gitlink.tag.notsemver' ) { _warnings = error.errors; return onnpm(null, npm); } callback(error); }