Expand description
The validation engine as the server uses it: compiled schemas for route
input declarations, text coercion, the error shape, and the
nitr.File handle for validated uploads.
Structs§
- Compiled
Schema - A compiled schema as the server sees it: the handle route
inputdeclarations are compiled into. - Custom
Format Info - What the document says about a script-defined format.
- Error
Entry - One failed rule.
- File
Info - What the spooler learned about an upload.
- LuaFile
- The
nitr.Fileuserdata. - Media
Type - One entry of the media-type table.
- Validation
Error - The verdict when validation fails: the summary, and every failing path with its message and rule.
Enums§
- Detection
- What the prefix of an upload says about it.
- DocSchema
- A documentation-only schema, as a route’s
doc.responses[n].schemamay give it: a compiled schema, a table of fields, or one rule table ({ type = "array", items = Note }). Never enforced; exported like a request schema so the document reads the same on both halves. - Text
Value - One text-part value: a string field, or a spooled upload.
Constants§
- MEDIA_
TYPES - Every type a
typeslist may name. - SNIFF_
BYTES - How many bytes detection reads.
Functions§
- compile_
doc_ schema - Compiles a documentation schema: a compiled schema or a table of
fields as
compile_schematakes them, or a single rule table recognised by itstypekey. - compile_
file_ rule - Compiles one
filerule for a"raw"body (input.body = { file = … }) as a one-field schema whose field is namedfile. - compile_
schema - Compiles a schema from what a script may hand a route: a field table
(rules as tables, shorthand strings or compiled schemas), or a compiled
nitr.validate.schemavalue.whatnames the site for errors. - compile_
text_ schema - Like
compile_schema, for a part whose values arrive as text (query, params, headers): nested kinds are refused, since a query string has no nesting. - custom_
formats - Every custom format registered in this state, sorted by name, for the
document’s
x-nitr-formatsvocabulary. - detect
- Sniffs the prefix.
- dimensions
- Header-only image dimensions, or
Nonewhen the header does not carry them (or is truncated). - executable_
extension - Whether a filename extension marks an executable regardless of bytes.
- fmt_
size - Byte counts print in the unit a person would pick:
512 B,2 KB,1.5 MB,3 GB. - freeze_
messages - Marks the state’s app-wide messages as frozen: the application has
compiled, and a
nitr.validate.messagescall from a handler raises. - is_
active_ content - Types a browser runs script from when it opens them. A family
wildcard (
image/*,text/*) never matches one; a rule has to name it, and naming it logs a warning at load. - is_text
- Whether the prefix is UTF-8 text without NUL or stray control bytes.
- lookup
- Looks a media type up by name.
- regex_
escape - Escapes every regex metacharacter so a literal stays a literal.
- rule_
codes - Every rule code a
messagestable may name. Unknown codes fail at load like unknown rule keys do: a typo must not silently override nothing. Every rule code anerrors[].rulemay carry, for the document’sValidationErrorcomponent. - text_
subtype_ matches - For a text-tier declared type, whether the prefix has the structure
the subtype implies (
{/[for JSON,<for XML and HTML,<svgfor SVG); plain text subtypes accept anything the sniffer accepted.
Type Aliases§
- Components
- Named component schemas collected while exporting: a titled schema
is emitted once under
components/schemas/<title>and referenced everywhere else. - Save
Resolver - Resolves a Lua-supplied relative path to the file
savemay rename the temporary to — the server’s containment rule, injected so this module knows nothing about upload roots.