Skip to content

Commit

Permalink
Fix author issue
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-dharti-r committed Jun 27, 2024
1 parent ca7b3d2 commit c2b8009
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion admin/src/api/post/content-types/post/lifecycles.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,56 +152,71 @@ function validateFields(result, is_from_update) {
return;
}

// set required message for summary,tags and meta_description
if (!result.title) {
const error = new YupValidationError({
path: "title",
message: "This value is required.",
});
throw error;
}

if (result.tags && result.tags.length == 0) {
const error = new YupValidationError({
path: "tags",
message: "This value is required.",
});
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) {
const error = new YupValidationError({
path: "author",
message: "This value is required.",
});
throw error;
}

if (!result.summary) {
const error = new YupValidationError({
path: "summary",
message: "This value is required.",
});
throw error;
}

if (result.summary && result.summary.length > 200) {
const error = new YupValidationError({
path: "summary",
message: "Allow max 200 chars only",
});
throw error;
}

if (!result.meta_description) {
const error = new YupValidationError({
path: "meta_description",
message: "This value is required.",
});
throw error;
}

if (result.meta_description && result.meta_description.length > 160) {
const error = new YupValidationError({
path: "meta_description",
message: "Allow max 160 chars only",
});
throw error;
}

if (result.blog_content == "") {
const error = new YupValidationError({
path: "blog_content",
Expand Down

0 comments on commit c2b8009

Please sign in to comment.