Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
export const validateEditableField = (fieldName, fieldValue) => {
switch (fieldName) {
case 'hflaWebsiteUrl':
return doesLinkContainFlex(fieldValue, 'hackforla.org');
case 'slackUrl':
return doesLinkContainFlex(fieldValue, 'slack.com');
case 'googleDriveUrl':
return doesLinkContainFlex(fieldValue, 'drive.google.com');
case 'githubUrl':
return doesLinkContainFlex(fieldValue, 'github.com');
case 'description':
return typeof fieldValue === 'string' && fieldValue.length <= 250;
default:
break;
}
return true;
};

export const generateErrorEditableField = (fieldName) => {
switch (fieldName) {
case 'hflaWebsiteUrl':
case 'slackUrl':
case 'googleDriveUrl':
case 'githubUrl':
return `Invalid field value for ${fieldName}`;
case 'description':
return 'Description is too long, max 250 characters allowed';
default:
break;
}
};

const doesLinkContainFlex = (link, key) => {
if (link.startsWith(`https://${key}`)) return true;
if (link.startsWith(`https://www.${key}`)) return true;
if (link.startsWith(key)) return true;
return false;
};