https://github.com/willothy/judge.lua
https://github.com/willothy/judge.lua
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/willothy/judge.lua
- Owner: willothy
- Created: 2024-10-21T02:11:40.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-21T06:23:38.000Z (over 1 year ago)
- Last Synced: 2025-08-01T02:44:15.344Z (11 months ago)
- Language: Lua
- Size: 2.93 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Judge
A tiny validation library for Lua.
```lua
local Judge = require("judge")
local MessageType = Judge.string().enum({ "ping", "pong" })
local ok, err = MessageType.validate("test")
if not ok then
print(err) -- invalid value: expected one of ping, pong, got test
end
local Message = Judge.object({
type = MessageType,
text = Judge.string().optional()
})
print(Message.validate({
type = "ping",
text = "Hello world!",
}))
```