debian-mirror-gitlab/app/assets/javascripts/projects/project_name_rules.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
570 B
JavaScript
Raw Normal View History

2023-03-04 22:38:38 +05:30
import { __ } from '~/locale';
const rulesReg = [
{
reg: /^[a-zA-Z0-9\u{00A9}-\u{1f9ff}_]/u,
msg: __("Name must start with a letter, digit, emoji, or '_'"),
},
{
reg: /^[a-zA-Z0-9\p{Pd}\u{002B}\u{00A9}-\u{1f9ff}_. ]+$/u,
msg: __("Name can contain only letters, digits, emojis, '_', '.', '+', dashes, or spaces"),
},
];
/**
*
* @param {string} text
* @returns {string} msg
*/
function checkRules(text) {
for (const item of rulesReg) {
if (!item.reg.test(text)) {
return item.msg;
}
}
return '';
}
export { checkRules };