required if for checked data
gitea/salix/dev This commit looks good Details

This commit is contained in:
Joan Sanchez 2019-03-13 08:35:25 +01:00
parent 6405688610
commit 5f5ce1a765
1 changed files with 2 additions and 1 deletions

View File

@ -73,6 +73,7 @@ module.exports = Self => {
Self.validateAsync('fi', tinIsValid, {
message: 'Invalid TIN'
});
let validateTin = require('../validations/validateTin');
async function tinIsValid(err, done) {
if (!this.isTaxDataChecked)
@ -85,7 +86,7 @@ module.exports = Self => {
let country = await Self.app.models.Country.findOne(filter);
let code = country ? country.code.toLowerCase() : null;
if (!validateTin(this.fi, code))
if (!this.fi || !validateTin(this.fi, code))
err();
done();
}