Schema<T = any>
A description of what shape a value must have, which you build with the schema functions to check and convert data.
A description of what shape a value must have, which you build with the schema functions to check and convert data.
Tests whether a value fits the schema, and gives the reason when it does not.
local ok, reason = stats:check({ name = "Ada", level = 1 })Use it forchecking an order a player sent from your shop before you act on it.
valueThe value to test.Gives a copy that fits the schema, or nil and the reason when it cannot.
local value, reason = stats:convert({ name = "Ada", level = "3" })Use it forcleaning up old saved data after you add new fields, which then take their defaults.
valueThe value to convert.Reads JSON text and converts it to fit the schema, or gives nil and the reason.
local value, reason = stats:from_json('{"name": "Ada", "level": 3}')Use it forloading settings or level data that you fetched from a web server as JSON text.
jsonJSON text.