Skip to content

Commit a86499c

Browse files
committed
fix: added org validation
1 parent 1467ae6 commit a86499c

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/components/OrgForm.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import type { FunctionComponent } from "react";
22
import Section from "./common/Section";
3-
import { FormControl, FormField, FormItem, FormLabel } from "./ui/form";
3+
import {
4+
FormControl,
5+
FormField,
6+
FormItem,
7+
FormLabel,
8+
FormMessage,
9+
} from "./ui/form";
410
import { Input } from "./ui/input";
511

612
interface OrgFormProps {
@@ -18,12 +24,18 @@ export const OrgForm: FunctionComponent<OrgFormProps> = ({
1824
<div className="mt-6">
1925
<FormField
2026
name="name"
27+
rules={{
28+
validate: (value) =>
29+
/[a-z0-9]/i.test(value ?? "") ||
30+
"The name must contain at least one letter or number.",
31+
}}
2132
render={({ field }) => (
2233
<FormItem>
2334
<FormLabel>Organization name*</FormLabel>
2435
<FormControl>
2536
<Input data-testid="org-name-label" {...field} />
2637
</FormControl>
38+
<FormMessage />
2739
</FormItem>
2840
)}
2941
/>

0 commit comments

Comments
 (0)