Skip to content

Commit

Permalink
Fix: model with required field that defaults to 0 can't be saved
Browse files Browse the repository at this point in the history
Number.prototype.validateRequiredInput() merely checked if the getter
for the field returned a truthy value. That fails if the default happens
to be zero (which is a falsy value).

The fix is to simply check if the return value is a number.
  • Loading branch information
jyrkive committed Sep 26, 2017
1 parent 0c8b41e commit d28bacc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fields/types/number/NumberType.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ number.prototype.validateInput = function (data, callback) {
number.prototype.validateRequiredInput = function (item, data, callback) {
var value = this.getValueFromData(data);
var result = !!(value || typeof value === 'number');
if (value === undefined && item.get(this.path)) {
if (value === undefined && typeof item.get(this.path) === 'number') {
result = true;
}
utils.defer(callback, result);
Expand Down

0 comments on commit d28bacc

Please sign in to comment.