Skip to main content

Module validate

Module validate 

Source
Expand description

Strict validation of caller-supplied values.

Everything the CoPilot API accepts ends up in a prompt, a SQL statement the agent is told to run, a filesystem path or a MemPalace wing, so each field is checked against a tight, allocation-free charset.

Constants§

LESSON_TYPES
MemPalace rooms a lesson may be filed under.
MAX_ALERT_ID
Largest accepted alert id (JavaScript’s Number.MAX_SAFE_INTEGER, so ids round-trip through CoPilot’s JSON without precision loss).
MAX_ALERT_ID_DIGITS
Max digits in a string-form alert id.
MAX_CUSTOMER_CODE_LEN
Max length of a customer code (MySQL VARCHAR(64)).
MAX_DRAWER_ID_LEN
Max length of a MemPalace drawer id.
MAX_INVESTIGATION_ID_LEN
Max length of an investigation id.
MAX_LESSON_CHARS
Max characters of a palace lesson.
MAX_QUERY_CHARS
Max characters of a palace search query.
MAX_TEMPLATE_NAME_LEN
Max length of a template override filename.
MAX_TRIGGERED_BY_LEN
Max length of a triggered_by label.
TRIGGERED_BY_VALUES
The triggered_by values CoPilot’s ai_analyst_job accepts.

Functions§

is_valid_customer_code
^[A-Za-z0-9_-]{1,64}$
is_valid_drawer_id
^[A-Za-z0-9_.:-]{1,256}$
is_valid_investigation_id
^[A-Za-z0-9_.:-]{1,128}$, not ./...
is_valid_lesson_type
Whether s names a MemPalace room.
is_valid_template_name
A plain .txt filename: ^[A-Za-z0-9._-]+\.txt$, at most 128 bytes, no leading dot (hidden files) and no .. anywhere.
is_valid_triggered_by
One of TRIGGERED_BY_VALUES. Anything else would make the agent’s job registration fail on the CoPilot side.
parse_alert_id
Parse a JSON alert id: a positive integer or a digit string.
parse_alert_id_str
Parse a string alert id: 1-16 ASCII digits, value in 1..=MAX_ALERT_ID.
sanitize_label
Trim, drop control characters, and truncate to max_chars characters. Used for display labels (user_name, sender) that end up in group names and chat metadata.
truncate_chars
Truncate to at most max_chars characters.