Browse Source

fix: use promise instead of callback for validation

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/3306/head
mertmit 2 years ago
parent
commit
2bbc8ee117
  1. 20
      packages/nc-gui-v2/utils/validation.ts

20
packages/nc-gui-v2/utils/validation.ts

@ -129,15 +129,17 @@ export const importExcelUrlValidator = {
} }
export const extraParameterValidator = { export const extraParameterValidator = {
validator: (rule: any, value: any, callback: (errMsg?: string) => void) => { validator: (rule: any, value: any) => {
for (const param of value) { return new Promise((resolve, reject) => {
if (param.key === '') { for (const param of value) {
callback('Parameter key cannot be empty') if (param.key === '') {
} return reject(new Error('Parameter key cannot be empty'))
if (value.filter((el: any) => el.key === param.key).length !== 1) { }
callback('Duplicate parameter keys are not allowed') if (value.filter((el: any) => el.key === param.key).length !== 1) {
return reject(new Error('Duplicate parameter keys are not allowed'))
}
} }
} return resolve(true)
callback() })
}, },
} }

Loading…
Cancel
Save