|
|
@ -73,37 +73,77 @@ function GetCaretPosition(ctrl) { |
|
|
|
return (CaretPos) |
|
|
|
return (CaretPos) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function validateTableName(v) { |
|
|
|
export function validateTableName(v, isGQL) { |
|
|
|
if (!v) { |
|
|
|
if (!v) { |
|
|
|
return 'Table name required' |
|
|
|
return "Table name required"; |
|
|
|
} |
|
|
|
|
|
|
|
if (/^[_A-Za-z][_0-9A-Za-z]*$/.test(v)) { |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (/^[^_A-Za-z]/.test(v)) { |
|
|
|
// GraphQL naming convention
|
|
|
|
return 'Name should start with an alphabet or _' |
|
|
|
// http://spec.graphql.org/June2018/#Name
|
|
|
|
} |
|
|
|
|
|
|
|
const m = v.match(/[^_A-Za-z\d]/g) |
|
|
|
if (isGQL) { |
|
|
|
if (m) { |
|
|
|
if (/^[_A-Za-z][_0-9A-Za-z]*$/.test(v)) { |
|
|
|
return `Following characters are not allowed ${m.map(c => JSON.stringify(c)).join(', ')}` |
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (/^[^_A-Za-z]/.test(v)) { |
|
|
|
|
|
|
|
return "Name should start with an alphabet or _"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const m = v.match(/[^_A-Za-z\d]/g); |
|
|
|
|
|
|
|
if (m) { |
|
|
|
|
|
|
|
return `Following characters are not allowed ${m |
|
|
|
|
|
|
|
.map((c) => JSON.stringify(c)) |
|
|
|
|
|
|
|
.join(", ")}`;
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// exclude . / \
|
|
|
|
|
|
|
|
// rest all characters allowed
|
|
|
|
|
|
|
|
// https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/n0rfg6x1shw0ppn1cwhco6yn09f7.htm#:~:text=By%20default%2C%20MySQL%20encloses%20column,not%20truncate%20a%20longer%20name.
|
|
|
|
|
|
|
|
const m = v.match(/[./\\]/g); |
|
|
|
|
|
|
|
if (m) { |
|
|
|
|
|
|
|
return `Following characters are not allowed ${m |
|
|
|
|
|
|
|
.map((c) => JSON.stringify(c)) |
|
|
|
|
|
|
|
.join(", ")}`;
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function validateColumnName(v) { |
|
|
|
export function validateColumnName(v, isGQL) { |
|
|
|
if (!v) { |
|
|
|
if (!v) { |
|
|
|
return 'Column name required' |
|
|
|
return "Column name required"; |
|
|
|
} |
|
|
|
|
|
|
|
if (/^[_A-Za-z][_0-9A-Za-z]*$/.test(v)) { |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (/^[^_A-Za-z]/.test(v)) { |
|
|
|
// GraphQL naming convention
|
|
|
|
return 'Name should start with an alphabet or _' |
|
|
|
// http://spec.graphql.org/June2018/#Name
|
|
|
|
} |
|
|
|
if (isGQL) { |
|
|
|
const m = v.match(/[^_A-Za-z\d]/g) |
|
|
|
if (/^[_A-Za-z][_0-9A-Za-z]*$/.test(v)) { |
|
|
|
if (m) { |
|
|
|
return true; |
|
|
|
return `Following characters are not allowed ${m.map(c => JSON.stringify(c)).join(', ')}` |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (/^[^_A-Za-z]/.test(v)) { |
|
|
|
|
|
|
|
return "Name should start with an alphabet or _"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const m = v.match(/[^_A-Za-z\d]/g); |
|
|
|
|
|
|
|
if (m) { |
|
|
|
|
|
|
|
return `Following characters are not allowed ${m |
|
|
|
|
|
|
|
.map((c) => JSON.stringify(c)) |
|
|
|
|
|
|
|
.join(", ")}`;
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// exclude . / \
|
|
|
|
|
|
|
|
// rest all characters allowed
|
|
|
|
|
|
|
|
// https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/n0rfg6x1shw0ppn1cwhco6yn09f7.htm#:~:text=By%20default%2C%20MySQL%20encloses%20column,not%20truncate%20a%20longer%20name.
|
|
|
|
|
|
|
|
const m = v.match(/[./\\]/g); |
|
|
|
|
|
|
|
if (m) { |
|
|
|
|
|
|
|
return `Following characters are not allowed ${m |
|
|
|
|
|
|
|
.map((c) => JSON.stringify(c)) |
|
|
|
|
|
|
|
.join(", ")}`;
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|