Skip to content

Commit

Permalink
add profanity filter to exisitng validation
Browse files Browse the repository at this point in the history
  • Loading branch information
chalabi2 committed Sep 2, 2024
1 parent 2bda059 commit dfabc0a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
9 changes: 6 additions & 3 deletions components/groups/forms/groups/GroupDetailsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
});

Expand Down
2 changes: 1 addition & 1 deletion components/groups/forms/groups/MemberInfoForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
});

Expand Down
11 changes: 8 additions & 3 deletions components/groups/forms/proposals/ProposalDetailsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
14 changes: 10 additions & 4 deletions components/groups/forms/proposals/ProposalMetadataForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit dfabc0a

Please sign in to comment.