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