AuthPlatform/src/validator/system/menu.lua

38 lines
1.2 KiB
Lua

---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by .
--- DateTime: 2025/11/04 11:12
--- 业务逻辑 对菜单数据进行参数数据的验证
local jsonschema = require("jsonschema")
local _M = {}
-- 定义一个JSON Schema
local schema = {
{type = "object", properties = {
{name = "menu_id", type = "string"},
{name = "menu_name", type = "string"},
{name = "parent_id", type = "string"},
{name = "order_num", type = "number"},
{name = "url", type = "string"},
{name = "target", type = "string"},
{name = "menu_type", type = "string"},
{name = "status", type = "string"},
{name = "is_refresh", type = "string"},
{name = "perms", type = "string"},
{name = "perms", type = "string"},
{name = "create_by", type = "string"},
{name = "update_by", type = "string"},
{name = "remark", type = "string"},
}, required = {"menu_id", "menu_name"}}
}
function _M.validatorJson(jsonData)
-- 验证数据是否符合schema
local validator = jsonschema.generate_validator(schema)
local result = validator(jsonData)
return result
end
return _M