Rules
Strings
String({ max }). max is required and counts UTF-8 characters. Invalid UTF-8 and control characters are rejected. multiline = true allows tab and line breaks only.Numbers
Number() and Integer() reject NaN and infinity. Integer turns 5.0 into 5. min and max are optional.Booleans and enums
Boolean(). Enum({ 'cash', 'bank' }) accepts listed strings, numbers or booleans only.Vectors
Vector2/3/4({ maxComponent? }) check the native type and finite components. Never trust them as positions.Arrays and maps
Array(item, { max }) and Map(key, value, { max }). max is required. Oversized tables are rejected before scanning the rest.Objects
Object({ field = rule }) rejects unknown keys by default. { strict = false } drops them instead. Wrap optional fields in Optional.A missing
max on String, Array or Map is an error in your editor and raises when the rule is built. Unbounded input cannot be accepted by accident.Validate yourself
Callbacks and net events validate for you. For other input, useValidate or Check:
args.n is the number of declared arguments, so table.unpack(args, 1, args.n) keeps trailing optional arguments.
Failure details
Details name the exact path that failed, for your server logs:invalid_args.
Custom checks
Every rule accepts avalidate function that runs after the built-in checks, on the normalized value:
true, or false with a message. A crashing validate fails with failed custom validation, without a stack.
Behavior to know
Validatetolerates trailingnilvalues and rejects extra ones. More than 8 extra arguments are rejected before unpacking.- Optional arguments MUST be trailing in
Define. - Validated tables are fresh copies. Metatables and unknown keys never pass through.
- Array items and map keys or values cannot be
Optional.