Socket
Socket
Sign inDemoInstall

grunt-tv4

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-tv4 - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

4

package.json
{
"name": "grunt-tv4",
"description": "Validate files against json-schema v4",
"version": "0.2.0",
"version": "0.2.1",
"homepage": "https://github.com/Bartvds/grunt-tv4",

@@ -51,4 +51,4 @@ "author": {

"peerDependencies": {
"grunt": "0.4.1"
"grunt": "~0.4.1"
}
}

@@ -112,2 +112,3 @@ # grunt-tv4

* 0.2.1 - Added support to report subErrors (for anyOf/oneOf)
* 0.2.0 - Updated to follow the Grunt conventions.

@@ -114,0 +115,0 @@ * 0.1.4 - Updated `tv4` to version `1.0.11`

@@ -23,3 +23,5 @@ /*

function valueStrim(value) {
function valueStrim(value, limit) {
limit = (typeof limit !== 'undefined' ? limit : 80);
var t = typeof value;

@@ -32,4 +34,4 @@ if (t === 'function') {

value = JSON.stringify(value);
if (value.length > 40) {
value = value.substr(0, 37) + '...';
if (value.length > limit) {
value = value.substr(0, limit - 3) + '...';
}

@@ -39,4 +41,4 @@ return value;

if (t === 'string') {
if (value.length > 40) {
return JSON.stringify(value.substr(0, 37)) + '...';
if (value.length > limit) {
return JSON.stringify(value.substr(0, limit - 3)) + '...';
}

@@ -55,3 +57,2 @@ return JSON.stringify(value);

//TODO decide to tv4 outside task for inter-target caching?
var taskTv4 = require('tv4').tv4.freshApi();

@@ -122,19 +123,22 @@ var jsonpointer = require('jsonpointer.js');

//subroutine
var printError = function (error, data, schema, indent) {
var printError = function (error, data, schema, indent, prefix) {
var value = jsonpointer.get(data, error.dataPath);
var schemaValue = jsonpointer.get(schema, error.schemaPath);
grunt.log.writeln(indent + error.message.yellow);
grunt.log.writeln(indent + indent + error.dataPath);
grunt.log.writeln(indent + indent + '-> value: ' + valueType(value) + ' -> ' + valueStrim(value));
prefix = (typeof prefix !== 'undefined' ? prefix : indent);
grunt.log.writeln(prefix + error.message.yellow);
grunt.log.writeln(prefix + indent + error.dataPath);
grunt.log.writeln(prefix + indent + '-> value: ' + valueType(value) + ' -> ' + valueStrim(value));
if (typeof schemaValue !== 'undefined') {
grunt.log.writeln(indent + indent + '-> schema: ' + schemaValue + ' -> ' + error.schemaPath);
grunt.log.writeln(prefix + indent + '-> schema: ' + schemaValue + ' -> ' + error.schemaPath);
}
else {
grunt.log.writeln(indent + indent + '-> schema-path: ' + error.schemaPath);
grunt.log.writeln(prefix + indent + '-> schema-path: ' + error.schemaPath);
}
//untested
/*grunt.util._.each(error.subErrors, function (error) {
printError(error, data, schema, indent + indent + indent + indent);
});*/
grunt.util._.each(error.subErrors, function (sub) {
printError(sub, data, schema, indent, prefix + indent);
});
};

@@ -165,3 +169,3 @@

else if (file.result.error) {
printError(file.result.error, file.data, file.schema, ' ');
printError(file.result.error, file.data, file.schema, ' ');
}

@@ -325,5 +329,5 @@ if (file.result.missing.length > 0) {

});
grunt.util._.each(context.options.formats, function (format, id) {
context.tv4.addFormat(id, format);
});
context.tv4.addFormat(context.options.formats);
grunt.util._.each(context.options.languages, function (language, id) {

@@ -338,6 +342,6 @@ context.tv4.addLanguage(id, language);

grunt.util._.each(this.files, function (f) {
grunt.util._.each(f.src, function (filePath) {
grunt.util._.some(f.src, function (filePath) {
if (!grunt.file.exists(filePath)) {
grunt.log.warn('file "' + filePath + '" not found.');
return false;
return true;
}

@@ -357,3 +361,3 @@ context.fileCount++;

if (context.options.add && Array.isArray(context.options.add)) {
grunt.util._.each(context.options.add, function (schema) {
grunt.util._.some(context.options.add, function (schema) {
if (typeof schema === 'string') {

@@ -367,3 +371,3 @@ //juggle

context.done(false);
return false;
return true;
}

@@ -370,0 +374,0 @@ context.tv4.addSchema(schema.id, schema);

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