Credit insurance validations fix

This commit is contained in:
Joan Sanchez 2018-03-26 11:43:17 +02:00
parent d29dcf2e11
commit 1cb9432922
1 changed files with 6 additions and 6 deletions

View File

@ -1,22 +1,22 @@
module.exports = function(Self) { module.exports = function(Self) {
require('../methods/creditInsurance/filter.js')(Self); require('../methods/creditInsurance/filter.js')(Self);
Self.validateCredit = function(credit) {
return credit >= 0;
};
Self.validateBinded('credit', Self.validateCredit, { Self.validateBinded('credit', Self.validateCredit, {
message: 'The credit must be an integer greater than or equal to zero', message: 'The credit must be an integer greater than or equal to zero',
allowNull: false, // FIXME: Ignored by loopback when it's false allowNull: false, // FIXME: Ignored by loopback when it's false
allowBlank: false allowBlank: false
}); });
Self.validateCredit = function(credit) { Self.validateGrade = function(grade) {
return (credit >= 0 && credit % 1 == 0); return typeof grade === 'undefined' || grade >= 0;
}; };
Self.validateBinded('grade', Self.validateGrade, { Self.validateBinded('grade', Self.validateGrade, {
message: 'The grade must be an integer greater than or equal to zero', message: 'The grade must be an integer greater than or equal to zero',
allowNull: true allowNull: true
}); });
Self.validateGrade = function(grade) {
return (typeof grade === 'undefined' || (grade >= 0 && grade % 1 == 0));
};
}; };