2021-10-08 13:23:40 +03:00
|
|
|
const ValueObject = require('./shared/ValueObject');
|
2021-10-07 17:42:56 +03:00
|
|
|
const InvalidOfferTitle = require('../../errors').InvalidOfferTitle;
|
|
|
|
|
|
|
|
/** @extends ValueObject<string> */
|
|
|
|
class OfferTitle extends ValueObject {
|
|
|
|
/** @param {unknown} title */
|
|
|
|
static create(title) {
|
|
|
|
if (!title || typeof title !== 'string') {
|
|
|
|
throw new InvalidOfferTitle({
|
|
|
|
message: 'Offer `display_title` must be a string.'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (title.length > 191) {
|
|
|
|
throw new InvalidOfferTitle({
|
|
|
|
message: 'Offer `display_title` can be a maximum of 191 characters.'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return new OfferTitle(title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = OfferTitle;
|