Introduction

🔥 Calid - Lua Schema Validation Resource

Calid is a Lua library designed for schema validation. It provides a set of tools to validate data structures, ensuring they meet specific requirements. This library is particularly useful for validating configurations, user inputs, or any structured data in Lua.


ℹ️ About the Project

Calid is heavily inspired by the Zod validation library from the JavaScript ecosystem. It aims to bring the same expressiveness and power to the Lua programming environment, especially for use cases like payload validation, data coercion, and configuration checking.

While Calid already implements many of Zod’s patterns (such as fluent chaining, nested schemas, and custom messages), it is still in early development. This means:

  • The resource may still undergo changes.
  • Some features from Zod may be partially implemented or missing.
  • There might be occasional inconsistencies or edge-case bugs.

Your feedback and contributions are highly appreciated to improve its stability and coverage.


🚀 Features

  • Validate various data types (primitives, objects, arrays) with precise rules.
  • Coerce inputs into the desired types automatically (string→number, number→string, boolean conversions).
  • Enforce complex constraints like regex patterns, value ranges, and membership in enums or literal sets.
  • Compose nested schemas for deep object and array structures.
  • Customize error messages and provide defaults for missing or optional fields.
  • Strip or passthrough unknown object properties to control input sanitation.
  • Integrate seamlessly into any frameworks.

📦 Installation

To enable the library inside your resource, add @calid/init.lua as a shared_script in your fxmanifest.lua file:

shared_scripts {
	"@calid/init.lua",
}