refactor: Simplify validateMCPServerName to match original ternary style

This commit is contained in:
Milan 2026-02-13 01:14:37 +02:00
parent 8fa2734830
commit 1d67476ed0

View file

@ -47,15 +47,7 @@ export const validateMCPServerUrl = (value: string) => {
};
export const validateMCPServerName = (value: string) => {
if (!value) return Promise.resolve();
if (value.includes("-")) {
return Promise.reject("Server name cannot contain '-' (hyphen). Please use '_' (underscore) instead.");
}
if (value.includes(" ")) {
return Promise.reject("Server name cannot contain spaces. Please use '_' (underscore) instead.");
}
return Promise.resolve();
return value && (value.includes("-") || value.includes(" "))
? Promise.reject("Server name cannot contain '-' (hyphen) or spaces. Please use '_' (underscore) instead.")
: Promise.resolve();
};