diff --git a/admin/src/api/post/content-types/post/lifecycles.js b/admin/src/api/post/content-types/post/lifecycles.js index 96b2984..e7315c2 100644 --- a/admin/src/api/post/content-types/post/lifecycles.js +++ b/admin/src/api/post/content-types/post/lifecycles.js @@ -151,7 +151,7 @@ function validateFields(result, is_from_update) { if (Object.keys(result).length <= 3) { return; } - + if (!result.title) { const error = new YupValidationError({ path: "title", @@ -167,17 +167,12 @@ function validateFields(result, is_from_update) { }); throw error; } - - // required author when add post - if (!is_from_update && result.author.connect.length == 0) { - const error = new YupValidationError({ - path: "author", - message: "This value is required.", - }); - throw error; - } - // required author when update post - if (is_from_update && result.author.disconnect.length > 0) { + + if ( + (result.author.disconnect.length > 0 && + result.author.connect.length == 0) || + (result.author.connect.length == 0 && result.author.disconnect.length == 0) + ) { const error = new YupValidationError({ path: "author", message: "This value is required.",