Skip to content

Commit f9bbd68

Browse files
authored
required() of value false throws fieldname is null
When trying to require boolean fields, value `false` should not thow an error.
1 parent 08bcb91 commit f9bbd68

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/services/required.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = function (...fieldNames) {
1414
fieldNames.forEach(name => {
1515
if (!existsByDot(item, name)) throw new errors.BadRequest(`Field ${name} does not exist. (required)`);
1616
const value = getByDot(item, name);
17-
if (!value && value !== 0) throw new errors.BadRequest(`Field ${name} is null. (required)`);
17+
if (!value && value !== 0 && value !== false) throw new errors.BadRequest(`Field ${name} is null. (required)`);
1818
});
1919
});
2020
};

0 commit comments

Comments
 (0)