33 lines
1003 B
Lua
33 lines
1003 B
Lua
---
|
|
--- Generated by EmmyLua(https://github.com/EmmyLua)
|
|
--- Created by .
|
|
--- DateTime: 2025/10/30 08:14
|
|
--- 业务逻辑 对应用数据参数进行数据的验证
|
|
local jsonschema = require("jsonschema")
|
|
|
|
local _M = {}
|
|
|
|
-- 定义一个JSON Schema
|
|
local schema = {
|
|
{type = "object", properties = {
|
|
{name = "name", type = "string"},
|
|
{name = "display_name", type = "string"},
|
|
{name = "logo", type = "string"},
|
|
{name = "title", type = "string"},
|
|
{name = "name", type = "string"},
|
|
{name = "favicon", type = "string"},
|
|
{name = "description", type = "string"},
|
|
{name = "homepage_url", type = "string"},
|
|
{name = "redirect_uris", type = "string"},
|
|
}, required = {"name", "redirect_uris"}}
|
|
}
|
|
|
|
function _M.validatorJson(jsonData)
|
|
-- 验证数据是否符合schema
|
|
local validator = jsonschema.generate_validator(schema)
|
|
local result = validator(jsonData)
|
|
return result
|
|
end
|
|
|
|
return _M
|