34 lines
687 B
JavaScript
34 lines
687 B
JavaScript
/**
|
|
* UpdateBlogCommand
|
|
* Blog módosítási command
|
|
*/
|
|
export class UpdateBlogCommand {
|
|
constructor(id, data) {
|
|
this.id = id;
|
|
this.title = data.title;
|
|
this.content = data.content;
|
|
this.published = data.published;
|
|
}
|
|
|
|
validate() {
|
|
const errors = [];
|
|
|
|
if (!this.id) {
|
|
errors.push('Blog ID is required');
|
|
}
|
|
|
|
if (this.title !== undefined && this.title.trim().length === 0) {
|
|
errors.push('Title cannot be empty');
|
|
}
|
|
|
|
if (this.content !== undefined && this.content.trim().length === 0) {
|
|
errors.push('Content cannot be empty');
|
|
}
|
|
|
|
return {
|
|
isValid: errors.length === 0,
|
|
errors
|
|
};
|
|
}
|
|
}
|