Makes the forms check the same limits on what users submit as the server enforces, by holding them in one place.
Returns handle as this instance writes it, isSelfHost telling its own
host. Another instance writes a user from here with this one's host,
bob@gerbeur.example, who is bob here: a mention or a link copied from
there names them so. Any other handle is returned as it is. The server
resolves names by it (resolveUsername, the mention notifications), and
the chat's highlight (mentionsUser) reads mentions by it.
Returns the name and, for a user from another instance, the host of
handle. splitHandle("alice@music.example") is
{ name: "alice", host: "music.example" }; a local name has no host.
The largest file a file dump may hold, in bytes. dump-service refuses a bigger one, and the create form before uploading it.
Matches an email address well enough to catch a typo; only the reset email arriving proves it.
Matches a whole handle (HANDLE_SOURCE).
The pattern of a handle, the name a user goes by on this instance: a local
user's username, or name@host for a user whose account lives on another
gerbeur (federation-service.ts stores it so in users.username). Paths,
mentions and the profile links all read names by it, through
HANDLE_RE, MENTION_RE (shared/mention.ts) and parsePagePath
(shared/paths.ts).
Matches a whole host (HOST_SOURCE).
The pattern of an instance's host as a handle writes it: DNS labels, and a
port for instances on one machine (localhost:8001). It ends on a letter or
a digit, so the period that ends a sentence after a mention isn't taken in.
HANDLE_SOURCE builds on it.
How often a dump's or a playlist's slug may change, counted from the aliases the changes left: 3 times a day. Moderators are exempt. slug-service refuses a change past it with a 429, and the edit forms say what the limit is.
Matches a valid username, made of letters, digits and underscores within the
VALIDATION limits. Sign-up and renaming check it on both sides. It uses the
same \w that a handle's pattern (HANDLE_SOURCE) reads a name with;
only a user from another instance has the @host part.
Matches an id the server makes with crypto.randomUUID(). A route checks
one before it names a file on disk, and shared/attachment.ts finds the
attachments a text links by it.
Read by the validators and services, which refuse what breaks a limit, and by the forms, which say so before sending. Lengths are JavaScript string lengths, so an emoji may count for two. The category limits are checked on the server only.
- CATEGORY_NAME_MAX: number
- CATEGORY_SLUG_MAX: number
- CHAT_MESSAGE_MAX: number
- COMMENT_BODY_MAX: number
-
DUMP_COMMENT_MAX: number
Applies to a dump's note, which the API calls its comment.
- DUMP_TITLE_MAX: number
- PASSWORD_MAX: number
- PASSWORD_MIN: number
- PLAYLIST_DESCRIPTION_MAX: number
- PLAYLIST_TITLE_MAX: number
- USERNAME_MAX: number
- USERNAME_MIN: number
- USER_DESCRIPTION_MAX: number
Usage
import * as mod from "shared/validation.ts";