mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-15 11:11:09 +00:00
16 lines
369 B
TypeScript
16 lines
369 B
TypeScript
import { normalizeOptionalString } from "./string-coerce.js";
|
|
|
|
export function coerceIdentityValue(
|
|
value: string | undefined,
|
|
maxLength: number,
|
|
): string | undefined {
|
|
const trimmed = normalizeOptionalString(value);
|
|
if (!trimmed) {
|
|
return undefined;
|
|
}
|
|
if (trimmed.length <= maxLength) {
|
|
return trimmed;
|
|
}
|
|
return trimmed.slice(0, maxLength);
|
|
}
|