$ luarocks install chotto
A TypeScript Zod-inspired validation library for Lua with luaCATS force type annotations!
'Chotto' means 'a little' in Japanese (**ちょっと**).
I hope this helps you 'a little' when adding types to Lua :D
- - -
local c = require('chotto')
-- Parse and validate
local string_result = c.string().parse('hello') -- ✓ returns 'hello'
local number_result = c.number().parse('hello') -- ✗ throws error because 'hello' is not a number
local boolean_result = c.boolean().parse(true) -- ✓ returns true
-- Safe validation with pcall -- when you don't want to throw errors
local ok, result = pcall(number_schema.parse, 10)
if ok then
print('Valid:', result) -- Valid: 10
else
print('Error:', result) -- Error message
end