DirkScripts Logo

Login With FiveM

Login

πŸ“š Library
β€Ί
Modules
β€Ί

validate

Validate

ℹ️ Shared Module

Build validation chains to assert value types, ranges, and custom constraints.

validate

Creates a new validation chain for a value.

lua
local name = validate(playerName).string(32).min(1).done()
local count = validate(amount).number().min(1).max(100).done()

Methods

MethodParametersDescription
.string(len?)len: number β€” optional max lengthAssert value is a string
.number()β€”Assert value is a number
.boolean()β€”Assert value is a boolean
.min(min)min: numberMinimum value (number) or minimum length (string)
.max(max)max: numberMaximum value (number) or maximum length (string)
.refine(fn, err?)fn: function(value) β†’ boolean, err: stringCustom validation function
.default(value)value: anyUse this value if the input is nil
.done()β€”Finalize and return the raw value

The chain can also be called directly β€” validate(x).string()() is equivalent to .done().

Example

lua
local function processPayment(data)
    local amount = validate(data.amount).number().min(1).max(10000).done()
    local note = validate(data.note).string(200).default('').done()
    local rush = validate(data.rush).boolean().default(false).done()
    
    -- Custom validation
    local code = validate(data.code).string().refine(function(v)
        return #v == 6
    end, 'Code must be 6 characters').done()
end

Copyright Β© 2026 DirkScripts.

Not affiliated with or endorsed by Rockstar North, Take-Two Interactive, or any other rights holders. FiveM is a copyright and registered trademark of Take-Two Interactive Software, Inc.
Our checkout system is provided by Tebex Limited, who manage payment processing, product delivery, and billing support. Prices shown in currencies other than GBP are approximate conversions updated daily. All purchases are processed in GBP, so the final amount charged may vary depending on your bank or payment provider’s exchange rate.