Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event Name Validation: blacklisted strings #1805

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
blacklist arr for event naming
  • Loading branch information
pluto-bell committed Oct 24, 2024
commit e3180037efead4934709e2f552c1a71aea3af189
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import validator from 'validator';
import { isWordInArrayInString } from './../../../utils/stringUtils.js';
import { eventNameBlacklistArr } from '../../../utils/blacklist.js';

const validateEventForm = (vals, projectToEdit) => {
let newErrors = {};
Expand All @@ -11,13 +12,13 @@ const validateEventForm = (vals, projectToEdit) => {
newErrors = { ...newErrors, name: 'Event name is required' };
} else if (
isWordInArrayInString(
['meeting', 'mtg'],
eventNameBlacklistArr,
vals[key].toLowerCase()
)
) {
newErrors = {
...newErrors,
name: "Event name cannot contain 'meeting' or 'mtg'",
name: `Event name cannot contain: ${vals[key]}`,
};
} else if (
isWordInArrayInString(
Expand Down
19 changes: 19 additions & 0 deletions client/src/utils/blacklist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export const eventNameBlacklistArr = [
'general',
'meet',
'meeting',
'mtg',
'onboarding',
'onboard',
'team',
'semi',
'bi',
'weekly',
'monthly',
'annual',
'annually',
'bi-weekly',
'twice-weekly',
'semi-annual',
'semi-annually',
]