|
|
|
@ -80,6 +80,32 @@ export const fieldRequiredValidator = () => {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const fieldLengthValidator = (sqlClientType: string) => { |
|
|
|
|
return { |
|
|
|
|
validator: (rule: any, value: any) => { |
|
|
|
|
const { t } = getI18n().global |
|
|
|
|
|
|
|
|
|
// no limit for sqlite but set as 255
|
|
|
|
|
let fieldLengthLimit = 255 |
|
|
|
|
|
|
|
|
|
if (sqlClientType === 'mysql2' || sqlClientType === 'mysql') { |
|
|
|
|
fieldLengthLimit = 64 |
|
|
|
|
} else if (sqlClientType === 'pg') { |
|
|
|
|
fieldLengthLimit = 59 |
|
|
|
|
} else if (sqlClientType === 'mssql') { |
|
|
|
|
fieldLengthLimit = 128 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
if (value?.length > fieldLengthLimit) { |
|
|
|
|
reject(new Error(t('msg.error.columnNameExceedsCharacters', { value: fieldLengthLimit }))) |
|
|
|
|
} |
|
|
|
|
resolve(true) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const importUrlValidator = { |
|
|
|
|
validator: (rule: any, value: any) => { |
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|