From d28bacce853c2e293e1aa6ad5b1116a3058d046c Mon Sep 17 00:00:00 2001
From: Jyrki Vesterinen <sandgtx@gmail.com>
Date: Tue, 26 Sep 2017 15:47:40 +0300
Subject: [PATCH 1/2] 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);

From 12de7af30ac679e917067e8f939739ce12d118a2 Mon Sep 17 00:00:00 2001
From: Jyrki Vesterinen <sandgtx@gmail.com>
Date: Tue, 26 Sep 2017 15:54:58 +0300
Subject: [PATCH 2/2] Fix: model with required field that defaults to false
 can't be saved

Boolean variant of commit d28bacce853c2e293e1aa6ad5b1116a3058d046c.
---
 fields/types/boolean/BooleanType.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fields/types/boolean/BooleanType.js b/fields/types/boolean/BooleanType.js
index 20c63070fd..220721e153 100644
--- a/fields/types/boolean/BooleanType.js
+++ b/fields/types/boolean/BooleanType.js
@@ -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);
 };