Documentation Index
Fetch the complete documentation index at: https://docs.sure-developer.com/llms.txt
Use this file to discover all available pages before exploring further.
Validator
Thevalidator module creates small schema objects that expose parse(data). A successful parse returns true. A failed parse raises Validation Error: ..., so wrap user-controlled inputs with pcall when you want to handle errors without stopping execution.
Basic schema
Rules
Marks a value as required. When
message is provided, that message overrides the default missing-field error.Sets a custom error message for the rule. The message is used when type or custom checks fail.
Requires a numeric value to be greater than or equal to
value.Requires a numeric value to be less than or equal to
value.Applies both
min(min) and max(max).Requires the parsed value to equal one entry in the given array.
Types
| Builder | Accepts |
|---|---|
v.object(fields) | A Lua table with named fields. |
v.array(itemRule) | A Lua array table where every item passes itemRule. |
v.string() | Lua string. |
v.number() | Lua number. |
v.integer() | Lua number with no fractional part. |
v.boolean() | Lua boolean, including false. |
v.callback() | Lua function. |
