diff --git a/src/controllers/units.controller.js b/src/controllers/units.controller.js index 2a20fb1a..34f45dbb 100644 --- a/src/controllers/units.controller.js +++ b/src/controllers/units.controller.js @@ -186,7 +186,15 @@ export const findAll = async (req, res) => { } where.marketplaceIdentifier = { - [Sequelize.Op.not]: [null, ''], + [Sequelize.Op.not]: null, + }; + } else { + if (!where) { + where = {}; + } + + where.marketplaceIdentifier = { + [Sequelize.Op.eq]: null, }; } diff --git a/src/validations/units.validations.js b/src/validations/units.validations.js index 3f92c362..90cd789e 100644 --- a/src/validations/units.validations.js +++ b/src/validations/units.validations.js @@ -23,7 +23,7 @@ const unitsBaseSchema = { unitType: Joi.string().custom(pickListValidation('unitType')).required(), marketplace: Joi.string().optional(), marketplaceLink: Joi.string().optional(), - marketplaceIdentifier: Joi.string().optional(), + marketplaceIdentifier: Joi.string().disallow('').allow(null).optional(), unitTags: Joi.string().allow('').optional(), unitStatus: Joi.string().custom(pickListValidation('unitStatus')).required(), unitStatusReason: Joi.string().when('unitStatus', {