From 726c9d32663d8633d52788250268d5f2252cd840 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 8 Mar 2024 06:39:23 +0100 Subject: [PATCH] refs #7004 fix: move validation to required method --- .../supplier/back/methods/supplier/updateFiscalData.js | 8 ++++++++ modules/supplier/back/models/supplier.js | 9 --------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/modules/supplier/back/methods/supplier/updateFiscalData.js b/modules/supplier/back/methods/supplier/updateFiscalData.js index f2cdd63be..4b2573dba 100644 --- a/modules/supplier/back/methods/supplier/updateFiscalData.js +++ b/modules/supplier/back/methods/supplier/updateFiscalData.js @@ -87,6 +87,14 @@ module.exports = Self => { } } + if (!city) { + throw new UserError('The city cannot be empty' + ); + } + if (!nif) { + throw new UserError('The nif cannot be empty' + ); + } return supplier.updateAttributes({ name, nif, diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index 2d3ffef3e..7e045d9d1 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -16,15 +16,6 @@ module.exports = Self => { Self.validatesPresenceOf('name', { message: 'The social name cannot be empty' }); - - Self.validatesPresenceOf('city', { - message: 'City cannot be empty' - }); - - Self.validatesPresenceOf('nif', { - message: 'The nif cannot be empty' - }); - Self.validatesUniquenessOf('nif', { message: 'TIN must be unique' });