add validation rules for museum code and change its textfield to use trim

This commit is contained in:
juhanikat
2025-08-28 14:57:11 +03:00
parent d302677ca4
commit ed864e1c6c
2 changed files with 6 additions and 1 deletions
@@ -30,7 +30,7 @@ export const MuseumInfoTab = ({ isNew }: { isNew?: boolean }) => {
['Country', dropdownWithSearch('country', countryOptions, 'Country')],
['State', textField('state')],
['State code', textField('state_code')],
['Museum code', textField('museum', { type: 'text', readonly: !isNew })],
['Museum code', textField('museum', { type: 'text', readonly: !isNew, trim: true })],
]
return (
+5
View File
@@ -19,6 +19,11 @@ export const validateMuseum = (editData: EditDataType<Museum>, fieldName: keyof
museum: {
name: 'Museum',
required: true,
asString: museumCode => {
if (museumCode.indexOf(' ') !== -1) return 'Museum code must not contain a space'
if (museumCode.toUpperCase() !== museumCode) return 'Museum code must only contains uppercase characters'
return null
},
},
institution: {
name: 'Institution',