{"id":"metamethods/typed","name":"typed","scope":"metamethods","platform":"roblox","description":"Mirrored from the Wally registry.","version":"0.8.2","latest":"0.8.2","versions":["0.8.2"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"87341a132f98b145830b3bb43d623a5746426f315ba20f33db5710685d71866b","likes":0,"downloads":0,"install":"forest install metamethods/typed","url":"https://forest.dev/p/roblox/metamethods/typed","files":"https://api.forest.dev/ai/package/roblox/metamethods/typed/files","readme":"> [!CAUTION]\n> library is still under development; use at your own risk\n\n# typed\n\nluau runtime type validation library\n\n## example\n\n```luau\nconst t = require(\"./lib\")\n\n-- define a user schema\nconst userSchema = t.table({\n\tusername = t.string({\n\t\tlength = {\n\t\t\tmin = 3,\n\t\t\tmax = 20,\n\t\t},\n\t}),\n\tage = t.number({ min = 18 }),\n\temail = t.optional(t.string({ match = \"^.+@.+%..+$\" })),\n\ttags = t.array(t.string()),\n})\n\n-- pull out the generated type using the infer type function\ntype User = t.infer<typeof(userSchema)>\n\nconst rawData = {\n\tusername = \"alex\",\n\tage = 25,\n\temail = \"alex@example.com\",\n\ttags = { \"admin\", \"developer\" },\n}\n\n-- attempt to validate and parse the raw data using the created schema\nconst result = userSchema.parse(rawData)\n\nif result.ok then\n\tconst user: User = result.value\n\tprint(user)\nelse\n\tprint(\"failed to validate:\", t.formatIssues(result.issues))\nend\n```\n\n## learn more\n\nyou can read the documentation [here](https://metamethods.github.io/typed)\n","readmeTruncated":false}