mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-08 10:22:46 +00:00
refactor(metadata): update code structure (#6765)
This commit is contained in:
21
frontend/src/metadata/utils/validate/view.js
Normal file
21
frontend/src/metadata/utils/validate/view.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { gettext } from '../../../utils/constants';
|
||||
|
||||
export const isValidViewName = (name, names) => {
|
||||
if (typeof name !== 'string') {
|
||||
return { isValid: false, message: gettext('Name should be string') };
|
||||
}
|
||||
name = name.trim();
|
||||
if (name === '') {
|
||||
return { isValid: false, message: gettext('Name is required') };
|
||||
}
|
||||
if (name.includes('/')) {
|
||||
return { isValid: false, message: gettext('Name cannot contain slash') };
|
||||
}
|
||||
if (name.includes('\\')) {
|
||||
return { isValid: false, message: gettext('Name cannot contain backslash') };
|
||||
}
|
||||
if (names.includes(name)) {
|
||||
return { isValid: false, message: gettext('Name already exists') };
|
||||
}
|
||||
return { isValid: true, message: name };
|
||||
};
|
Reference in New Issue
Block a user