mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-19 22:10:51 +00:00
17 lines
349 B
TypeScript
17 lines
349 B
TypeScript
export function coerceIdentityValue(
|
|
value: string | undefined,
|
|
maxLength: number,
|
|
): string | undefined {
|
|
if (typeof value !== "string") {
|
|
return undefined;
|
|
}
|
|
const trimmed = value.trim();
|
|
if (!trimmed) {
|
|
return undefined;
|
|
}
|
|
if (trimmed.length <= maxLength) {
|
|
return trimmed;
|
|
}
|
|
return trimmed.slice(0, maxLength);
|
|
}
|