Extended character limit for post content
This commit is contained in:
@@ -45,6 +45,7 @@ export default function CommentInputModule() {
|
|||||||
);
|
);
|
||||||
console.log("Comment created succesfully", response.data);
|
console.log("Comment created succesfully", response.data);
|
||||||
resetForm(); // Reset the form after successful submission
|
resetForm(); // Reset the form after successful submission
|
||||||
|
window.location.reload();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -18,11 +18,10 @@ const validationSchema = Yup.object({
|
|||||||
.min(3, "Title must be at least 3 characters")
|
.min(3, "Title must be at least 3 characters")
|
||||||
.max(200, "Title must be at most 200 characters")
|
.max(200, "Title must be at most 200 characters")
|
||||||
.required("Title is required"),
|
.required("Title is required"),
|
||||||
|
|
||||||
content: Yup.string()
|
content: Yup.string()
|
||||||
.trim()
|
.trim()
|
||||||
.min(3, "Content must be at least 3 characters")
|
.min(3, "Content must be at least 3 characters")
|
||||||
.max(500, "Content must be at most 500 characters")
|
.max(3000, "Content must be at most 3000 characters")
|
||||||
.required("Content is required"),
|
.required("Content is required"),
|
||||||
postImage: Yup.mixed(),
|
postImage: Yup.mixed(),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -17,19 +17,11 @@ const validationSchema = Yup.object({
|
|||||||
.trim()
|
.trim()
|
||||||
.min(3, "Title must be at least 3 characters")
|
.min(3, "Title must be at least 3 characters")
|
||||||
.max(200, "Title must be at most 200 characters")
|
.max(200, "Title must be at most 200 characters")
|
||||||
.matches(
|
|
||||||
/^[a-zA-Z0-9\s]+$/,
|
|
||||||
"Title can only contain letters, numbers, and spaces"
|
|
||||||
)
|
|
||||||
.required("Title is required"),
|
.required("Title is required"),
|
||||||
content: Yup.string()
|
content: Yup.string()
|
||||||
.trim()
|
.trim()
|
||||||
.min(3, "Content must be at least 3 characters")
|
.min(3, "Content must be at least 3 characters")
|
||||||
.max(500, "Content must be at most 500 characters")
|
.max(3000, "Content must be at most 3000 characters")
|
||||||
.matches(
|
|
||||||
/^[a-zA-Z0-9,\s!"'-]*$/,
|
|
||||||
"Only letters, numbers, commas, spaces, exclamation marks, quotations, and common symbols are allowed"
|
|
||||||
)
|
|
||||||
.required("Content is required"),
|
.required("Content is required"),
|
||||||
postImage: Yup.mixed(),
|
postImage: Yup.mixed(),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ router.post(
|
|||||||
// Validate request body
|
// Validate request body
|
||||||
let validationSchema = yup.object({
|
let validationSchema = yup.object({
|
||||||
title: yup.string().trim().min(3).max(200).required(),
|
title: yup.string().trim().min(3).max(200).required(),
|
||||||
content: yup.string().trim().min(3).max(500).required(),
|
content: yup.string().trim().min(3).max(3000).required(),
|
||||||
userId: yup.string().required(),
|
userId: yup.string().required(),
|
||||||
postImage: yup.string().trim().max(255),
|
postImage: yup.mixed(),
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
data = await validationSchema.validate(data, { abortEarly: false });
|
data = await validationSchema.validate(data, { abortEarly: false });
|
||||||
@@ -191,7 +191,7 @@ router.put(
|
|||||||
// Validate request body
|
// Validate request body
|
||||||
let validationSchema = yup.object({
|
let validationSchema = yup.object({
|
||||||
title: yup.string().trim().min(3).max(200).required(),
|
title: yup.string().trim().min(3).max(200).required(),
|
||||||
content: yup.string().trim().min(3).max(500).required(),
|
content: yup.string().trim().min(3).max(3000).required(),
|
||||||
postImage: yup.mixed(),
|
postImage: yup.mixed(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user