From d28bacce853c2e293e1aa6ad5b1116a3058d046c Mon Sep 17 00:00:00 2001 From: Jyrki Vesterinen Date: Tue, 26 Sep 2017 15:47:40 +0300 Subject: [PATCH] Fix: model with required field that defaults to 0 can't be saved 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. --- fields/types/number/NumberType.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fields/types/number/NumberType.js b/fields/types/number/NumberType.js index 5c4c6b8ae1..65c7714d59 100644 --- a/fields/types/number/NumberType.js +++ b/fields/types/number/NumberType.js @@ -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);