Zod-like
Make everything looks like Zod (reference), Easy to learn if you have familiar with Zod.
Lua, Data Validation, FiveM (Purpose)
local somePlayerData = {
identifier = 123,
name = 'John Stone'
}
local playerSchema <const> = prism:object({
identifier = prism:string().identifier(),
name = prism:string()
})
local data, errorMessage = playerSchema.parse(somePlayerData)
if errorMessage then
error(errorMessage)
--[[
errorMessage => {
code = 'invalid_type',
path = 'identifier',
message = 'Invalid type. Received: number, expected: string'
}
]]
else
--[[
data => {
identifier = 'steam:112233445566',
name = 'John Stone'
}
]]
end