Extended character limit for post content

This commit is contained in:
Rykkel
2024-08-13 12:51:45 +08:00
parent 4d191d3443
commit f55145b5ca
4 changed files with 6 additions and 14 deletions

View File

@@ -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 (

View File

@@ -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(),
}); });

View File

@@ -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(),
}); });

View File

@@ -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(),
}); });