harmadik gyakorlat
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user