salix/services/client/common/models/credit-insurance.js

23 lines
741 B
JavaScript

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