add url regex to community link

Signed-off-by: Lykke Axlin <lykkeaxlin@hotmail.com>

Co-authored-by: klaraab <klarabroman@live.se>
This commit is contained in:
Lykke Axlin
2021-10-13 16:35:43 +02:00
parent 809b6d85c6
commit e5679eb27c
2 changed files with 12 additions and 7 deletions
@@ -25,7 +25,7 @@ type Props = {
control: Control<FormValues, object>;
helperText?: string;
placeholder?: string;
required: boolean;
rules?: Object;
};
export const InputField = ({
@@ -34,7 +34,7 @@ export const InputField = ({
control,
helperText,
placeholder,
required,
rules,
}: Props) => {
const label =
inputType.charAt(0).toLocaleUpperCase('en-US') + inputType.slice(1);
@@ -43,9 +43,7 @@ export const InputField = ({
<Controller
name={inputType}
control={control}
rules={{
required: required,
}}
rules={rules}
render={({ field }) => (
<TextField
{...field}
@@ -144,16 +144,23 @@ export const ProjectDialog = ({
<InputField
error={errors.announcement}
control={control}
required
rules={{
required: true,
}}
inputType="announcement"
helperText="please enter an announcement"
placeholder="Describe who you are and what skills you are looking for"
/>
<InputField
error={errors.community}
control={control}
required={false}
rules={{
required: false,
pattern: RegExp('^(https?)://[^s$.?#].[^s]*$'),
}}
inputType="community"
helperText="please enter a link starting with http/https"
placeholder="Community link to e.g. Teams or Discord"
/>