hmpo-form-wizard 12.0.5 → 12.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/validation/index.js
CHANGED
|
@@ -88,9 +88,11 @@ function validate(fields, key, value, context) {
|
|
|
88
88
|
// validate against field options
|
|
89
89
|
if ((field.options || field.items) && !field._validateFieldOptions) {
|
|
90
90
|
field._validateFieldOptions = true;
|
|
91
|
+
const items = (field.options || field.items).filter(i => !i.divider);
|
|
92
|
+
const values = items.map(o => typeof o === 'string' ? o : o.value);
|
|
91
93
|
field.validate.push({
|
|
92
94
|
type: 'equal',
|
|
93
|
-
arguments:
|
|
95
|
+
arguments: values
|
|
94
96
|
});
|
|
95
97
|
}
|
|
96
98
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hmpo-form-wizard",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"description": "Routing and request handling for a multi-step form processes",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"nyc": "^15.1.0",
|
|
44
44
|
"proxyquire": "^2.1.3",
|
|
45
45
|
"reqres": "^3.0.1",
|
|
46
|
-
"sinon": "^
|
|
46
|
+
"sinon": "^15.0.1",
|
|
47
47
|
"sinon-chai": "^3.7.0"
|
|
48
48
|
},
|
|
49
49
|
"mocha": {
|
|
@@ -205,6 +205,19 @@ describe('validation', () => {
|
|
|
205
205
|
fields.field.validate[0].arguments.should.deep.equal([ 'number', 'one', 'two', 'three' ]);
|
|
206
206
|
});
|
|
207
207
|
|
|
208
|
+
it('does not add divider items to the equality validator', () => {
|
|
209
|
+
fields = {
|
|
210
|
+
'field': {
|
|
211
|
+
items: [ 'number', 'one', { divider: 'or' }, 'two', 'three' ]
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
validation.validate(fields, 'field');
|
|
216
|
+
fields.field.validate.should.have.length(1);
|
|
217
|
+
fields.field.validate[0].type.should.equal('equal');
|
|
218
|
+
fields.field.validate[0].arguments.should.deep.equal([ 'number', 'one', 'two', 'three' ]);
|
|
219
|
+
});
|
|
220
|
+
|
|
208
221
|
it('should not add the options validator twice', () => {
|
|
209
222
|
fields = {
|
|
210
223
|
'field': {
|