Files
GKNB_MSTM071/Backend/harmadik gyakorlat/src/application/commands/UpdateBlogCommand.js
T
2026-02-25 20:16:03 +01:00

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
};
}
}