From 08d3e6e99cc5177190efc7266a63c95d7ba2493f Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Fri, 8 Oct 2021 12:40:57 +0200 Subject: [PATCH] Allowed for OfferDescription to be null/empty refs https://github.com/TryGhost/Team/issues/1083 OfferDescription is not a required field, so we must not throw when it is falsy or not present. --- ghost/offers/lib/domain/models/OfferDescription.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ghost/offers/lib/domain/models/OfferDescription.js b/ghost/offers/lib/domain/models/OfferDescription.js index 4c36dd0043..c656a98390 100644 --- a/ghost/offers/lib/domain/models/OfferDescription.js +++ b/ghost/offers/lib/domain/models/OfferDescription.js @@ -5,7 +5,11 @@ const InvalidOfferDescription = require('../errors').InvalidOfferDescription; class OfferDescription extends ValueObject { /** @param {unknown} description */ static create(description) { - if (!description || typeof description !== 'string') { + if (description === null || description === undefined) { + return new OfferDescription(''); + } + + if (typeof description !== 'string') { throw new InvalidOfferDescription({ message: 'Offer `display_description` must be a string.' });