From 5f5ce1a76516213f5ed706c67c368453dcfb67b3 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 13 Mar 2019 08:35:25 +0100 Subject: [PATCH] required if for checked data --- modules/client/back/models/client.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index aa5f5cc0b..803e91605 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -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(); }