* chore: add translations for validation messages (#345) * chore: add validation texts to locale file * feat: switch all validations from plain text to use i18n locale * feat: switch review form validations from plain text to use locale file * run translation script --------- Co-authored-by: Iniubong Obonguko <[email protected]>
This commit is contained in:
co-authored by
Iniubong Obonguko
parent
4dd25a84ea
commit
563418cbf4
+30
-10
@@ -45,26 +45,46 @@
|
||||
const review = reviews.find((r) => r.id === id);
|
||||
const reviewSchema = z.object({
|
||||
name: z.string().min(5, {
|
||||
message: 'Name is too short, min of 5 character',
|
||||
invalid_type_error: 'Must not be empty'
|
||||
message: `${$t(
|
||||
'course.navItem.landing_page.editor.reviews_form.validations.name.min_char'
|
||||
)}`,
|
||||
invalid_type_error: `${$t(
|
||||
'course.navItem.landing_page.editor.reviews_form.validations.invalid_type_error'
|
||||
)}`
|
||||
}),
|
||||
avatar_url: z.string().min(6, {
|
||||
message: 'Upload an image',
|
||||
invalid_type_error: 'Must not be empty'
|
||||
message: `${$t(
|
||||
'course.navItem.landing_page.editor.reviews_form.validations.avatar_url.message'
|
||||
)}`,
|
||||
invalid_type_error: `${$t(
|
||||
'course.navItem.landing_page.editor.reviews_form.validations.invalid_type_error'
|
||||
)}`
|
||||
}),
|
||||
rating: z
|
||||
.number()
|
||||
.min(1, {
|
||||
message: 'Rating must be from 1-5',
|
||||
invalid_type_error: 'Must not be empty'
|
||||
message: `${$t(
|
||||
'course.navItem.landing_page.editor.reviews_form.validations.rating.message'
|
||||
)}`,
|
||||
invalid_type_error: `${$t(
|
||||
'course.navItem.landing_page.editor.reviews_form.validations.invalid_type_error'
|
||||
)}`
|
||||
})
|
||||
.max(5, {
|
||||
message: 'Rating must be from 1-5',
|
||||
invalid_type_error: 'Must not be empty'
|
||||
message: `${$t(
|
||||
'course.navItem.landing_page.editor.reviews_form.validations.rating.message'
|
||||
)}`,
|
||||
invalid_type_error: `${$t(
|
||||
'course.navItem.landing_page.editor.reviews_form.validations.invalid_type_error'
|
||||
)}`
|
||||
}),
|
||||
description: z.string().min(10, {
|
||||
message: 'Description is too short, min of 5 character',
|
||||
invalid_type_error: 'Must not be empty'
|
||||
message: `${$t(
|
||||
'course.navItem.landing_page.editor.reviews_form.validations.description.min_char'
|
||||
)}`,
|
||||
invalid_type_error: `${$t(
|
||||
'course.navItem.landing_page.editor.reviews_form.validations.invalid_type_error'
|
||||
)}`
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user