piggy-proof
Advanced tools
Comparing version
{ | ||
"name": "piggy-proof", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Validate an object of properties meets given validation rules", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -21,2 +21,3 @@ var RuleParser = require('./rule-parser'); | ||
Object.keys(data).forEach(function(field) { | ||
if (parsedRules[field] === undefined) { return; } // continue to next loop | ||
validationResults[field] = []; | ||
@@ -23,0 +24,0 @@ |
@@ -25,2 +25,16 @@ var expect = require('chai').expect; | ||
it('should ignore fields that do not exist on the model', function(done) { | ||
var data = { | ||
username: '', | ||
password: 'ab1', | ||
noExistField: 'asdf' | ||
}; | ||
expect(PiggyProof.validate(data, 'users')).to.deep.equal({ | ||
username: [ 'is not present' ], | ||
password: [ 'is below the minimum length' ] | ||
}); | ||
done(); | ||
}); | ||
it('should determine whether validation results are valid', function(done) { | ||
@@ -27,0 +41,0 @@ var invalidData = { |
14880
2.98%393
3.42%