hmpo-form-controller
Advanced tools
+0
-1
@@ -5,5 +5,4 @@ language: node_js | ||
| - "0.12" | ||
| - "iojs" | ||
| notifications: | ||
| email: false | ||
| sudo: false |
@@ -45,3 +45,3 @@ var _ = require('underscore'), | ||
| } | ||
| if (!dependent || (dependent && values[dependent.field] === dependent.value)) { | ||
| if (!dependent || (dependent && !fields[dependent.field]) || (dependent && values[dependent.field] === dependent.value)) { | ||
| return true; | ||
@@ -48,0 +48,0 @@ } else { |
+1
-1
| { | ||
| "name": "hmpo-form-controller", | ||
| "version": "0.2.5", | ||
| "version": "0.3.0", | ||
| "description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+119
-11
@@ -613,3 +613,4 @@ var Form = require('../../'); | ||
| var form, oldFormatters; | ||
| var form, oldFormatters, req, res, cb; | ||
| beforeEach(function () { | ||
@@ -631,2 +632,11 @@ oldFormatters = _.clone(Form.formatters); | ||
| }); | ||
| res = {}; | ||
| cb = sinon.stub(); | ||
| }); | ||
| afterEach(function () { | ||
| Form.formatters = oldFormatters; | ||
| }); | ||
| it('should clean the values with an appropriately formatted empty value if a dependency is not met', function () { | ||
| form = new Form({ | ||
@@ -663,10 +673,3 @@ template: 'index', | ||
| }); | ||
| }); | ||
| afterEach(function () { | ||
| Form.formatters = oldFormatters; | ||
| }); | ||
| it('should clean the values with an appropriately formatted empty value if a dependency is not met', function () { | ||
| var req = request({ | ||
| req = request({ | ||
| flash: sinon.stub(), | ||
@@ -681,4 +684,3 @@ form: { | ||
| } | ||
| }), res = {}; | ||
| var cb = sinon.stub(); | ||
| }); | ||
@@ -698,2 +700,108 @@ form._validate(req, res, cb); | ||
| it('should be validated if the dependency exists in the step\'s fields and the value matches', function () { | ||
| form = new Form({ | ||
| template: 'index', | ||
| fields: { | ||
| 'is-thing': { | ||
| validate: [ | ||
| 'required' | ||
| ] | ||
| }, | ||
| 'is-thing-b': { | ||
| validate: [ | ||
| 'required' | ||
| ], | ||
| dependent: { | ||
| field: 'is-thing', | ||
| value: 'true' | ||
| } | ||
| } | ||
| } | ||
| }); | ||
| req = request({ | ||
| form: { | ||
| values: { | ||
| 'is-thing': 'true', | ||
| 'is-thing-b': '' | ||
| } | ||
| } | ||
| }); | ||
| form._validate(req, res, cb); | ||
| cb.should.have.been.calledWith({ | ||
| 'is-thing-b': new form.Error('is-thing-b', { type: 'required' }) | ||
| }); | ||
| }); | ||
| it('should be validated if the dependency doesn\'t exist in the step\'s fields', function () { | ||
| form = new Form({ | ||
| template: 'index', | ||
| fields: { | ||
| 'is-thing': { | ||
| validate: [ | ||
| 'required' | ||
| ] | ||
| }, | ||
| 'is-thing-b': { | ||
| validate: [ | ||
| 'required' | ||
| ], | ||
| dependent: { | ||
| field: 'is-not-a-thing', | ||
| value: 'true' | ||
| } | ||
| } | ||
| } | ||
| }); | ||
| req = request({ | ||
| form: { | ||
| values: { | ||
| 'is-thing': 'true', | ||
| 'is-thing-b': '' | ||
| } | ||
| } | ||
| }); | ||
| form._validate(req, res, cb); | ||
| cb.should.have.been.calledWith({ | ||
| 'is-thing-b': new form.Error('is-thing-b', { type: 'required' }) | ||
| }); | ||
| }); | ||
| it('shouldn\'t be validated if the dependency exists but the value doesn\'t match', function () { | ||
| form = new Form({ | ||
| template: 'index', | ||
| fields: { | ||
| 'is-thing': { | ||
| validate: [ | ||
| 'required' | ||
| ] | ||
| }, | ||
| 'is-thing-b': { | ||
| validate: [ | ||
| 'required' | ||
| ], | ||
| dependent: { | ||
| field: 'is-thing', | ||
| value: 'false' | ||
| } | ||
| } | ||
| } | ||
| }); | ||
| req = request({ | ||
| form: { | ||
| values: { | ||
| 'is-thing': 'false', | ||
| 'is-thing-b': '' | ||
| } | ||
| } | ||
| }); | ||
| form._validate(req, res, cb); | ||
| cb.should.have.been.calledWith(); | ||
| }); | ||
| }); | ||
@@ -700,0 +808,0 @@ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
65754
6.02%1625
6.42%1
Infinity%