feat: add social media links to user profile
- Add YouTube, Instagram, Facebook, and TikTok URL fields to User model - Create database migration for social media link columns - Add custom validators to ensure URLs contain correct domains - Update profile page with social media input fields - Include social media URLs in GET /api/users/me response - Add icons for each social platform in the UI Users can now add links to their social media profiles. Each field validates that the URL contains the appropriate domain (e.g., instagram.com for Instagram, youtube.com/youtu.be for YouTube).
This commit is contained in:
@@ -136,6 +136,38 @@ const updateProfileValidation = [
|
||||
.trim()
|
||||
.matches(/^\d{0,10}$/)
|
||||
.withMessage('WSDC ID must be numeric and up to 10 digits'),
|
||||
body('youtubeUrl')
|
||||
.optional()
|
||||
.trim()
|
||||
.custom((value) => {
|
||||
if (!value) return true; // Allow empty
|
||||
return value.includes('youtube.com') || value.includes('youtu.be');
|
||||
})
|
||||
.withMessage('Must be a valid YouTube URL (youtube.com or youtu.be)'),
|
||||
body('instagramUrl')
|
||||
.optional()
|
||||
.trim()
|
||||
.custom((value) => {
|
||||
if (!value) return true; // Allow empty
|
||||
return value.includes('instagram.com');
|
||||
})
|
||||
.withMessage('Must be a valid Instagram URL (instagram.com)'),
|
||||
body('facebookUrl')
|
||||
.optional()
|
||||
.trim()
|
||||
.custom((value) => {
|
||||
if (!value) return true; // Allow empty
|
||||
return value.includes('facebook.com') || value.includes('fb.com');
|
||||
})
|
||||
.withMessage('Must be a valid Facebook URL (facebook.com or fb.com)'),
|
||||
body('tiktokUrl')
|
||||
.optional()
|
||||
.trim()
|
||||
.custom((value) => {
|
||||
if (!value) return true; // Allow empty
|
||||
return value.includes('tiktok.com');
|
||||
})
|
||||
.withMessage('Must be a valid TikTok URL (tiktok.com)'),
|
||||
handleValidationErrors,
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user