/** * The rule for a saved view's name, and the only copy of it. * * Both places a name can be set consult this: **Create New View** * (`CreateScreenPopup`) and **Rename** on a row (`ViewItem`). They are the same * field with the same constraint, and a second copy would have been a second * constraint the moment one of them changed — the class of drift the * `getCustomViewFields` and `operatorNeedsValue` helpers exist to prevent. * * Client-side this covers only what the user can be told immediately. The * server owns **uniqueness**, and answers a duplicate with HTTP 422; both * callers map that to a message rather than trying to pre-empt it, because the * list they would check against is per-user and already stale by the time it is * rendered. */ export const VIEW_NAME_MAX_LENGTH = 25; /** `""` when the name is usable, otherwise the message to show under the field. */ export const validateViewName = (value: string): string => { if (!value.trim()) return "Required"; if (value.length > VIEW_NAME_MAX_LENGTH) return `Maximum ${VIEW_NAME_MAX_LENGTH} characters allowed`; return ""; };