issues/27: validate only fields present in resource config

This commit is contained in:
Valery Petrov
2026-05-20 14:08:08 +03:00
committed by Valeriy Petrov
parent 67388d9628
commit 40fcfc303e
+4 -3
View File
@@ -241,13 +241,14 @@ export const ContentEditPage = ({ config, hooks, isCreate = false }) => {
const validateClient = () => { const validateClient = () => {
const next = {} const next = {}
if (!String(form.name ?? '').trim()) { const has = (key) => config.fields.some((f) => f.key === key)
if (has('name') && !String(form.name ?? '').trim()) {
next.name = 'Название не может быть пустым' next.name = 'Название не может быть пустым'
} }
if (!String(form.alias ?? '').trim()) { if (has('alias') && !String(form.alias ?? '').trim()) {
next.alias = 'Alias не может быть пустым' next.alias = 'Alias не может быть пустым'
} }
if (form.regionId === '' || form.regionId == null) { if (has('regionId') && (form.regionId === '' || form.regionId == null)) {
next.regionId = 'Укажите регион' next.regionId = 'Укажите регион'
} }
return next return next