Skip to main content

Module validation

Module validation 

Source
Expand description

Shared field-validation tags for mod-authored inputs.

A validation tag on a crate::ui::UiField or a crate::mod_config::ModParameter names a rule set that both the launcher (live, while the user types) and the backend (authoritative, on receipt) enforce identically. The rules live here, one module, so the client-side refusal and a server-side one can never drift apart: the tournament room-name check is mirrored in PHP by contract, and both sides quote the same limits and charsets.

Two tags ship with this launcher generation:

  • PLAYER_NAME_TAG, the tournament player identity: 1 to 9 ASCII letters. The name travels inside every replay .dat and lands in the game’s high-times table, so it stays as narrow as the game’s own name handling needs.
  • ROOM_NAME_TAG, the room display name: up to 24 printable extended-ASCII characters (what a 1999 Windows application displays without surprises: ASCII 0x20-0x7E plus the Latin-1 supplement 0xA0-0xFF; the name lands in ANSI game files). Empty is valid, the server autogenerates a snowboarding word pair for it.

Unknown tags are rejected by ModUi::validate / ModConfig::validate (parse liberally, validate strictly, same mechanism as unknown popup kinds) so a newer mod on an older launcher reports itself instead of silently skipping the check.

Constants§

KNOWN_TAGS
Every tag this launcher generation knows.
PLAYER_NAME_TAG
The tournament player-name rule: 1 to 9 ASCII letters (a-z, A-Z).
ROOM_NAME_TAG
The room display-name rule: up to 24 printable extended-ASCII characters, empty means the server autogenerates one.

Functions§

is_known_tag
Whether tag names a rule set this launcher enforces.
validate_player_name
The player-name rule set: trimmed, 1 to 9 ASCII letters. Returns the trimmed name, or the reason the input was refused.
validate_room_name
The room-name rule set: empty is fine (server autogenerates), otherwise up to 24 printable extended-ASCII characters.
validate_value
Validates one value against the rule set tag names.