mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-11 22:13:20 +03:00
35f150bcf4
no-issue More cleanup to pull files into their appropriate responsibility
25 lines
797 B
JavaScript
25 lines
797 B
JavaScript
const ValueObject = require('./shared/ValueObject');
|
|
const InvalidOfferDescription = require('../errors').InvalidOfferDescription;
|
|
|
|
/** @extends ValueObject<string> */
|
|
class OfferDescription extends ValueObject {
|
|
/** @param {unknown} description */
|
|
static create(description) {
|
|
if (!description || typeof description !== 'string') {
|
|
throw new InvalidOfferDescription({
|
|
message: 'Offer `display_description` must be a string.'
|
|
});
|
|
}
|
|
|
|
if (description.length > 191) {
|
|
throw new InvalidOfferDescription({
|
|
message: 'Offer `display_description` can be a maximum of 191 characters.'
|
|
});
|
|
}
|
|
|
|
return new OfferDescription(description);
|
|
}
|
|
}
|
|
|
|
module.exports = OfferDescription;
|