comments implement
This commit is contained in:
1 parent
9e0bef2527
commit
4b6ecfbf5d
41 files changed
+1350
-13
No files matched your search
@@ -0,0 +1,27 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user