We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a2c52fe commit ad8db59Copy full SHA for ad8db59
src/lib/coerce.js
@@ -100,11 +100,7 @@ exports.valObjects = {
100
otherOpts: ['dflt', 'noBlank', 'strict', 'arrayOk', 'values'],
101
coerceFunction: function(v, propOut, dflt, opts) {
102
if(typeof v !== 'string') {
103
- var okToCoerce = (
104
- typeof v === 'number' ||
105
- v instanceof Date ||
106
- typeof v === 'boolean'
107
- );
+ var okToCoerce = (typeof v === 'number');
108
109
if(opts.strict === true || !okToCoerce) propOut.set(dflt);
110
else propOut.set(String(v));
test/jasmine/tests/lib_test.js
@@ -529,7 +529,7 @@ describe('Test lib.js:', function() {
529
.toEqual(dflt);
530
531
expect(coerce({s: true}, {}, stringAttrs, 's'))
532
- .toEqual('true');
+ .toEqual(dflt);
533
534
expect(coerce({s: {1: 2}}, {}, stringAttrs, 's'))
535
@@ -878,12 +878,12 @@ describe('Test lib.js:', function() {
878
it('should work for valType \'string\' where', function() {
879
var date = new Date(2016, 1, 1);
880
881
- assert(['3', '4', 'a', 3, 1.2113, '', date, false], [undefined, {}, [], null], {
+ assert(['3', '4', 'a', 3, 1.2113, ''], [undefined, {}, [], null, date, false], {
882
valType: 'string',
883
dflt: 'a'
884
});
885
886
- assert(['3', '4', 'a', 3, 1.2113, date, true], ['', undefined, {}, [], null], {
+ assert(['3', '4', 'a', 3, 1.2113], ['', undefined, {}, [], null, date, true], {
887
888
dflt: 'a',
889
noBlank: true
0 commit comments