[api] 2025 inventions

This commit is contained in:
Devin Zuczek
2026-08-29 14:40:57 -04:00
parent 750413f240
commit 5aea5a4cf9
5 changed files with 1488 additions and 73 deletions
+17
View File
@@ -61,6 +61,15 @@ export const MIN_INVENTION_NAME_LENGTH = 3
export const MAX_INVENTION_NAME_LENGTH = 24
export const MAX_INVENTION_DESCRIPTION_LENGTH = 512
/**
* The long description — the blurb on an invention's detail page, as opposed to the one
* line that fits under a browse tile. The client sends it on `v9/save` and edits it
* through `v2/metadata`, and how long it lets one get has not been pinned down, so the cap
* here is this server's own: generous enough that no real blurb hits it, small enough that
* a record stays a record. It is checked only when a caller actually sends one.
*/
export const MAX_INVENTION_LONG_DESCRIPTION_LENGTH = 4096
/**
* One invention tag. Short and letters-only because tags are a controlled vocabulary the
* browse chips are derived from (see `getInventionTagFilters`) — a tag with digits,
@@ -180,6 +189,14 @@ export function inventionDescriptionRejection(value: string): string | null {
return null
}
/** Why a long description can't be stored, or null when it can. */
export function inventionLongDescriptionRejection(value: string): string | null {
if (glyphLength(value) > MAX_INVENTION_LONG_DESCRIPTION_LENGTH) {
return `Invention long descriptions can be at most ${MAX_INVENTION_LONG_DESCRIPTION_LENGTH} characters.`
}
return null
}
/**
* Why an invention tag is unacceptable, or `null` when it's fine. Pass the NORMALIZED
* tag (trimmed and lowercased, as `setInventionTags` stores it) — checking what was typed