From dfabc0a946349d41d56b4d1a11115dbe027acea9 Mon Sep 17 00:00:00 2001 From: Joseph Chalabi <100090645+chalabi2@users.noreply.github.com> Date: Mon, 2 Sep 2024 01:15:07 -0700 Subject: [PATCH] add profanity filter to exisitng validation --- .../groups/forms/groups/GroupDetailsForm.tsx | 9 ++++++--- components/groups/forms/groups/MemberInfoForm.tsx | 2 +- .../groups/forms/proposals/ProposalDetailsForm.tsx | 11 ++++++++--- .../forms/proposals/ProposalMetadataForm.tsx | 14 ++++++++++---- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/components/groups/forms/groups/GroupDetailsForm.tsx b/components/groups/forms/groups/GroupDetailsForm.tsx index 2322e6a7..6f830304 100644 --- a/components/groups/forms/groups/GroupDetailsForm.tsx +++ b/components/groups/forms/groups/GroupDetailsForm.tsx @@ -10,15 +10,18 @@ const GroupSchema = Yup.object().shape({ title: Yup.string().required('Title is required').max(50, 'Title must not exceed 50 characters'), authors: Yup.string() .required('Authors are required') - .max(200, 'Authors must not exceed 200 characters'), + .max(200, 'Authors must not exceed 200 characters') + .noProfanity('Profanity is not allowed'), summary: Yup.string() .required('Summary is required') .min(10, 'Summary must be at least 10 characters') - .max(500, 'Summary must not exceed 500 characters'), + .max(500, 'Summary must not exceed 500 characters') + .noProfanity('Profanity is not allowed'), description: Yup.string() .required('Description is required') .min(20, 'Description must be at least 20 characters') - .max(1000, 'Description must not exceed 1000 characters'), + .max(1000, 'Description must not exceed 1000 characters') + .noProfanity('Profanity is not allowed'), forumLink: Yup.string().url('Invalid URL format'), }); diff --git a/components/groups/forms/groups/MemberInfoForm.tsx b/components/groups/forms/groups/MemberInfoForm.tsx index 1d7287f0..9d4ce385 100644 --- a/components/groups/forms/groups/MemberInfoForm.tsx +++ b/components/groups/forms/groups/MemberInfoForm.tsx @@ -10,7 +10,7 @@ const MemberSchema = Yup.object().shape({ address: Yup.string() .test('is-valid-address', 'Invalid address format', value => isValidAddress(value || '')) .required('Required'), - name: Yup.string().required('Required'), + name: Yup.string().required('Required').noProfanity('Profanity is not allowed'), weight: Yup.number().min(1, 'Must be at least 1').required('Required'), }); diff --git a/components/groups/forms/proposals/ProposalDetailsForm.tsx b/components/groups/forms/proposals/ProposalDetailsForm.tsx index e0e65264..31945dc4 100644 --- a/components/groups/forms/proposals/ProposalDetailsForm.tsx +++ b/components/groups/forms/proposals/ProposalDetailsForm.tsx @@ -6,14 +6,19 @@ import Link from 'next/link'; import { PiAddressBook } from 'react-icons/pi'; import { TextInput, TextArea } from '@/components/react/inputs'; const ProposalSchema = Yup.object().shape({ - title: Yup.string().required('Title is required').max(50, 'Title must not exceed 50 characters'), + title: Yup.string() + .required('Title is required') + .max(50, 'Title must not exceed 50 characters') + .noProfanity('Profanity is not allowed'), proposers: Yup.string() .required('Proposer is required') - .max(200, 'Proposers must not exceed 200 characters'), + .max(200, 'Proposers must not exceed 200 characters') + .noProfanity('Profanity is not allowed'), summary: Yup.string() .required('Summary is required') .min(10, 'Summary must be at least 10 characters') - .max(500, 'Summary must not exceed 500 characters'), + .max(500, 'Summary must not exceed 500 characters') + .noProfanity('Profanity is not allowed'), }); export default function ProposalDetails({ diff --git a/components/groups/forms/proposals/ProposalMetadataForm.tsx b/components/groups/forms/proposals/ProposalMetadataForm.tsx index 7db13afe..57d58c66 100644 --- a/components/groups/forms/proposals/ProposalMetadataForm.tsx +++ b/components/groups/forms/proposals/ProposalMetadataForm.tsx @@ -5,18 +5,24 @@ import { ProposalFormData, ProposalAction } from '@/helpers/formReducer'; import { TextInput, TextArea } from '@/components/react/inputs'; const ProposalSchema = Yup.object().shape({ - title: Yup.string().required('Title is required').max(50, 'Title must not exceed 50 characters'), + title: Yup.string() + .required('Title is required') + .max(50, 'Title must not exceed 50 characters') + .noProfanity('Profanity is not allowed'), authors: Yup.string() .required('Authors are required') - .max(200, 'Authors must not exceed 200 characters'), + .max(200, 'Authors must not exceed 200 characters') + .noProfanity('Profanity is not allowed'), summary: Yup.string() .required('Summary is required') .min(10, 'Summary must be at least 10 characters') - .max(500, 'Summary must not exceed 500 characters'), + .max(500, 'Summary must not exceed 500 characters') + .noProfanity('Profanity is not allowed'), details: Yup.string() .required('Details are required') .min(10, 'Details must be at least 10 characters') - .max(500, 'Summary must not exceed 500 characters'), + .max(500, 'Summary must not exceed 500 characters') + .noProfanity('Profanity is not allowed'), }); export default function ProposalMetadataForm({