28 lines
705 B
TypeScript
28 lines
705 B
TypeScript
export class CommentContent {
|
|
static readonly MAX_LENGTH = 10000;
|
|
|
|
private constructor(private readonly _value: string) {}
|
|
|
|
static create(value: string): CommentContent {
|
|
const trimmed = value?.trim();
|
|
|
|
if (!trimmed) {
|
|
throw new Error('Комментарий не может быть пустым');
|
|
}
|
|
|
|
if (trimmed.length > CommentContent.MAX_LENGTH) {
|
|
throw new Error(`Комментарий не может превышать ${CommentContent.MAX_LENGTH} символов`);
|
|
}
|
|
|
|
return new CommentContent(trimmed);
|
|
}
|
|
|
|
get value(): string {
|
|
return this._value;
|
|
}
|
|
|
|
equals(other: CommentContent): boolean {
|
|
return this._value === other.value;
|
|
}
|
|
}
|