Browse Source

feat(gui-v2): duplicate column name validation

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2857/head
Pranav C 2 years ago
parent
commit
3ce82329fc
  1. 18
      packages/nc-gui-v2/composables/useColumnCreateStore.ts

18
packages/nc-gui-v2/composables/useColumnCreateStore.ts

@ -45,6 +45,24 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
required: true,
message: 'Column name is required',
},
// validation for unique column name
{
validator: (rule: any, value: any, callback: (errMsg?: string) => void) => {
if (
meta.value?.columns?.some(
(c) =>
c.id !== formState.value.id && // ignore current column
// compare against column_name and title
((value || '').toLowerCase() === (c.column_name || '').toLowerCase() ||
(value || '').toLowerCase() === (c.title || '').toLowerCase()),
)
) {
callback('Duplicate column name')
}
callback()
},
},
],
uidt: [
{

Loading…
Cancel
Save