diff --git a/src/bed-admission/bed-tag/bed-tags-admin-form.component.tsx b/src/bed-admission/bed-tag/bed-tags-admin-form.component.tsx index 76342f6..d684dff 100644 --- a/src/bed-admission/bed-tag/bed-tags-admin-form.component.tsx +++ b/src/bed-admission/bed-tag/bed-tags-admin-form.component.tsx @@ -19,7 +19,21 @@ import { Location } from "@openmrs/esm-framework"; import type { BedTagData } from "../../types"; const BedTagAdministrationSchema = z.object({ - name: z.string().max(255), + name: z + .string() + .max(255) + .refine( + (value) => { + return ( + typeof value === "string" && + value.trim().length > 0 && + !/\d/.test(value) + ); + }, + { + message: "Bed tag name must not contain numbers", + } + ), }); interface BedTagAdministrationFormProps { @@ -88,6 +102,7 @@ const BedTagsAdministrationForm: React.FC = ({ ( <> { + return ( + typeof value === "string" && + value.trim().length > 0 && + !/\d/.test(value) + ); + }, + { + message: "Bed Name must be a non-empty string without numbers", + } + ), + displayName: z + .string() + .max(255) + .refine( + (value) => { + return ( + typeof value === "string" && + value.trim().length > 0 && + !/\d/.test(value) + ); + }, + { + message: "Display name must be a non-empty string without numbers", + } + ), description: z.string().max(255), }); @@ -92,6 +120,7 @@ const BedTypeAdministrationForm: React.FC = ({ ( <> = ({ ( <> = ({ ( <>