Skip to content

Commit

Permalink
Merge pull request #4397 from jyrkive/required-number-with-default
Browse files Browse the repository at this point in the history
Fix: model with required field that defaults to 0 can't be saved
  • Loading branch information
Noviny committed Jan 22, 2018
2 parents eb7ef63 + 12de7af commit ce14c51
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fields/types/boolean/BooleanType.js
Expand Up @@ -36,7 +36,7 @@ boolean.prototype.validateInput = function (data, callback) {

boolean.prototype.validateRequiredInput = function (item, data, callback) {
var value = this.getValueFromData(data);
var result = (value && value !== 'false') || item.get(this.path) ? true : false;
var result = (value && value !== 'false') || typeof item.get(this.path) === 'boolean' ? true : false;
utils.defer(callback, result);
};

Expand Down
2 changes: 1 addition & 1 deletion fields/types/number/NumberType.js
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 ce14c51

Please sign in to comment.