{
  "classes": [
    {
      "constants": [],
      "types": [],
      "name": "@eryx/schema",
      "tags": [],
      "functions": [
        {
          "source": {
            "path": "",
            "line": 51
          },
          "is_method": false,
          "signature": "schema.literal<T>(\n    literal: ((T & (string | number | boolean)) | \"__MAGIC_USED_FOR_IMPLICIT_LITERAL_VALUES_NARROWING__\")?  -- Exact value this schema must match.\n) → (\n      -- A literal schema. \n)",
          "owner": "schema",
          "desc": "Create a schema that matches exactly one literal value.\nTypical usage is in union branches and tagged object fields, for example\n`kind = schema.literal(\"user\")`.",
          "tags": [],
          "name": "literal",
          "return_str": "LiteralSchema<T>",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "LiteralSchema<T>",
              "desc": "A literal schema. "
            }
          ],
          "params": [
            {
              "lua_type": "((T & (string | number | boolean)) | \"__MAGIC_USED_FOR_IMPLICIT_LITERAL_VALUES_NARROWING__\")?",
              "name": "literal",
              "desc": "Exact value this schema must match."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 231
          },
          "is_method": false,
          "signature": "schema.number(\n    metadata: NumberMetadata?  -- Internal metadata snapshot used when deriving chained schemas.\n) → (\n      -- A number schema. \n)",
          "owner": "schema",
          "desc": "Create a number schema.\nBy default, this schema accepts any runtime number and applies no extra\nconstraints until modifiers are chained.",
          "tags": [],
          "name": "number",
          "return_str": "NumberSchema",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "NumberSchema",
              "desc": "A number schema. "
            }
          ],
          "params": [
            {
              "lua_type": "NumberMetadata?",
              "name": "metadata",
              "desc": "Internal metadata snapshot used when deriving chained schemas."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 420
          },
          "is_method": false,
          "signature": "schema.string(\n    metadata: StringMetadata?  -- Internal metadata snapshot used when deriving chained schemas.\n) → (\n      -- A string schema. \n)",
          "owner": "schema",
          "desc": "Create a string schema.\nBy default, this accepts any runtime string and applies no additional\nconstraints until modifiers are chained.",
          "tags": [],
          "name": "string",
          "return_str": "StringSchema",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "StringSchema",
              "desc": "A string schema. "
            }
          ],
          "params": [
            {
              "lua_type": "StringMetadata?",
              "name": "metadata",
              "desc": "Internal metadata snapshot used when deriving chained schemas."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 48
          },
          "is_method": false,
          "signature": "schema.boolean<T>() → (\n      -- A boolean schema. \n)",
          "owner": "schema",
          "desc": "Create a schema that accepts boolean values.\nThe returned schema is intentionally minimal and composes cleanly inside\ntable, map, optional, and union schemas.",
          "tags": [],
          "name": "boolean",
          "return_str": "BooleanSchema",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "BooleanSchema",
              "desc": "A boolean schema. "
            }
          ],
          "params": []
        },
        {
          "source": {
            "path": "",
            "line": 170
          },
          "is_method": false,
          "signature": "schema.array<T>(\n    of: t.Schema<T>,  -- Child schema applied to each numeric-indexed element.\n    metadata: ArrayMetadata<T>?  -- Internal metadata snapshot used for chained schema derivation.\n) → (\n      -- An array schema. \n)",
          "owner": "schema",
          "desc": "Create an array schema for values validated by a child schema.\nChild schemas can be primitive or composed; nested errors are path-prefixed\nusing array indices (for example `#2`).",
          "tags": [],
          "name": "array",
          "return_str": "ArraySchema<T>",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "ArraySchema<T>",
              "desc": "An array schema. "
            }
          ],
          "params": [
            {
              "lua_type": "t.Schema<T>",
              "name": "of",
              "desc": "Child schema applied to each numeric-indexed element."
            },
            {
              "lua_type": "ArrayMetadata<T>?",
              "name": "metadata",
              "desc": "Internal metadata snapshot used for chained schema derivation."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 487
          },
          "is_method": false,
          "signature": "schema.table<T>(\n    fields: T & { [string]: t.Schema<any> },  -- Field map where each key points to a child schema.\n    options: TableOptions?  -- Optional unknown-key/catchall/readonly configuration.\n) → (\n      -- A table schema. \n)",
          "owner": "schema",
          "desc": "Create a table schema from field definitions.\nEach key maps to a child schema. By default, unknown keys are rejected\nunless policy is changed via struct helpers.",
          "tags": [],
          "name": "table",
          "return_str": "TableSchema<t.stripIndexer<T>>",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "TableSchema<t.stripIndexer<T>>",
              "desc": "A table schema. "
            }
          ],
          "params": [
            {
              "lua_type": "T & { [string]: t.Schema<any> }",
              "name": "fields",
              "desc": "Field map where each key points to a child schema."
            },
            {
              "lua_type": "TableOptions?",
              "name": "options",
              "desc": "Optional unknown-key/catchall/readonly configuration."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 85
          },
          "is_method": false,
          "signature": "schema.optional<T>(\n    child: t.Schema<T>,  -- Schema used when input is not nil.\n    options: { hasDefault: boolean, defaultValue: T? }?  -- Internal optional metadata, including default configuration.\n) → (\n      -- An optional schema. \n)",
          "owner": "schema",
          "desc": "Create an optional schema around a child schema.\nUse this to model fields that may be absent. For predictable downstream\nshapes, pair with `:default(...)`.",
          "tags": [],
          "name": "optional",
          "return_str": "OptionalSchema<T>",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "OptionalSchema<T>",
              "desc": "An optional schema. "
            }
          ],
          "params": [
            {
              "lua_type": "t.Schema<T>",
              "name": "child",
              "desc": "Schema used when input is not nil."
            },
            {
              "lua_type": "{ hasDefault: boolean, defaultValue: T? }?",
              "name": "options",
              "desc": "Internal optional metadata, including default configuration."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 54
          },
          "is_method": false,
          "signature": "schema.anyOf<T>(\n    ...: T | t.Schema<any>\n) → (\n      -- A union schema. \n)",
          "owner": "schema",
          "desc": "Create a union schema that succeeds when any child schema matches.\nRaw literal values are promoted to literal schemas.\nThis allows concise declarations like `schema.anyOf(\"a\", \"b\", 3)`.\nAt least one branch is required.",
          "tags": [],
          "name": "anyOf",
          "return_str": "UnionSchema<t.extractChildrenFromAnyOfUnion<T>>",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "UnionSchema<t.extractChildrenFromAnyOfUnion<T>>",
              "desc": "A union schema. "
            }
          ],
          "params": [
            {
              "lua_type": "T | t.Schema<any>",
              "name": "...",
              "desc": ""
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 76
          },
          "is_method": false,
          "signature": "schema.map<T, U>(\n    key: T | t.Schema<any>,  -- Schema (or literal shorthand) used to validate map keys.\n    value: U | t.Schema<any>  -- Schema (or literal shorthand) used to validate map values.\n) → (\n      -- A map schema. \n)",
          "owner": "schema",
          "desc": "Create a map schema from key and value schemas (or literal shorthands).\nLiteral key/value inputs are promoted automatically, allowing concise forms\nlike `schema.map(\"status\", \"ok\")` when strict constants are desired.",
          "tags": [],
          "name": "map",
          "return_str": "MapSchema<t.extractSchemaType<T>, t.extractSchemaType<U>>",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "MapSchema<t.extractSchemaType<T>, t.extractSchemaType<U>>",
              "desc": "A map schema. "
            }
          ],
          "params": [
            {
              "lua_type": "T | t.Schema<any>",
              "name": "key",
              "desc": "Schema (or literal shorthand) used to validate map keys."
            },
            {
              "lua_type": "U | t.Schema<any>",
              "name": "value",
              "desc": "Schema (or literal shorthand) used to validate map values."
            }
          ]
        }
      ],
      "properties": [],
      "source": {
        "path": "",
        "line": 0
      },
      "desc": "@module @eryx/schema\n\nRuntime schema construction, validation, and parsing.\n\nThis module is the public entrypoint for value schemas. It is designed\nfor runtime data boundaries: request bodies, config files, CLI input,\npersisted payloads, plugin data, and any other dynamic values that should\nbe validated before your application logic depends on them.\n\n## Why schemas instead of ad-hoc checks?\n\nWithout schemas, validation logic tends to spread across call sites and\ndiverge over time. With schemas, you define the contract once and reuse it:\n- one place for validation rules,\n- one consistent parse/validation behavior,\n- one composable unit for nested and shared types.\n\n## `parse` vs `validate`\n\nEvery schema provides two runtime entrypoints:\n- `parse(value)` -> `(ok, parsedOrError)`\n- `validate(value)` -> `boolean`\n\n`validate` is for pass/fail checks.\n`parse` is for pass/fail plus normalized output.\n\nUse `parse` when:\n- you depend on transformed output (for example string trimming/casing),\n- you want actionable error messages,\n- you are at an external boundary and need diagnostics.\n\nUse `validate` when:\n- you only need a boolean gate,\n- you do not need transformed output or error details.\n\n## Quick Start\n\n```luau\nlocal schema = require(\"@eryx/schema\")\n\nlocal User = schema.table({\n\tid = schema.number():int():positive(),\n\tname = schema.string():trimWhitespace():minLen(1),\n\temail = schema.optional(schema.string()),\n})\n\nlocal ok, parsedOrErr = User:parse({\n\tid = 7,\n\tname = \"  Ada  \",\n})\n-- ok == true\n-- parsedOrErr.name == \"Ada\"\n```\n\n## Available Constructors\n\n### `schema.literal(value)`\nMatches exactly one literal value (string/number/boolean/nil).\n\nGood for:\n- discriminators (for example `kind = \"user\"`),\n- protocol constants,\n- strict mode flags.\n\n```luau\nlocal Kind = schema.literal(\"user\")\n```\n\n### `schema.boolean()`\nValidates booleans.\n\nGood for:\n- feature switches,\n- toggle fields in payloads.\n\n### `schema.number()`\nValidates numbers and supports chainable numeric constraints.\n\nCommon constraints:\n- range checks: `:gt`, `:gte`, `:lt`, `:lte`\n- sign checks: `:positive`, `:nonnegative`, `:negative`, `:nonpositive`\n- divisibility: `:multipleOf`\n- integer-only: `:int`\n\n```luau\nlocal Port = schema.number():int():gte(1):lte(65535)\n```\n\n### `schema.string()`\nValidates strings and supports both validation and parse-time mutation.\n\nCommon validators:\n- size: `:minLen`, `:maxLen`, `:length`\n- pattern matching: `:match` (Lua patterns), `:regex`\n- containment: `:startsWith`, `:endsWith`, `:includes`\n- casing: `:isUpperCase`, `:isLowerCase`\n\nCommon mutators:\n- `:trimWhitespace()`\n- `:toUpperCase()`\n- `:toLowerCase()`\n\nUse mutators when you want canonicalized output from `parse`.\nUse validators when you want strict input acceptance criteria.\n\n### `schema.array(childSchema)`\nValidates list-like tables where each element must satisfy a child schema.\n\nCommon constraints:\n- `:minLen`\n- `:maxLen`\n- `:length`\n- `:nonempty`\n\n```luau\nlocal Tags = schema.array(schema.string():trimWhitespace()):nonempty()\n```\n\n### `schema.optional(childSchema)`\nWraps a schema so `nil` is accepted.\n\nYou can provide a default at parse time:\n```luau\nlocal RetryCount = schema.optional(schema.number():int()):default(3)\n```\n\n### `schema.anyOf(...)`\nUnion schema. Parsing succeeds if any branch succeeds.\nBranches can be schemas or raw literals.\n\n```luau\nlocal Role = schema.anyOf(\"admin\", \"member\", \"guest\")\n```\n\n### `schema.map(keySchema, valueSchema)`\nValidates key/value tables by validating both keys and values.\nBoth key and value schemas can be full schemas or literals.\n\nGood for:\n- dynamic dictionaries,\n- metadata bags with constrained key/value types.\n\n## Table Schemas\n\n`schema.table({...})` creates object-like schemas with named fields.\n\nDefault behavior is strict:\n- unknown keys fail parse,\n- required keys must be present,\n- optional fields are represented with `schema.optional(...)`.\n\n```luau\nlocal Config = schema.table({\n\thost = schema.string(),\n\tport = schema.number():int(),\n\ttls = schema.optional(schema.boolean()):default(false),\n})\n```\n\n## Struct Helpers (`@eryx/schema/struct`)\n\nTable schemas are created here with `schema.table(...)`.\nTable transformation helpers (strict/strip/passthrough/catchall/extend/etc)\nare provided by `@eryx/schema/struct`.\n\n```luau\nlocal Base = schema.table({ a = schema.number() })\n\nlocal struct = require(\"@eryx/schema/struct\")\nlocal Strict = struct.strict(Base)\nlocal Strip = struct.strip(Base)\nlocal Pass = struct.passthrough(Base)\n```\n\nCommon helpers from `@eryx/schema/struct`:\n- unknown key policy:\n  - `strict`\n  - `strip`\n  - `passthrough`\n  - `catchall`\n- shape transforms:\n  - `partial`\n  - `pick`\n  - `omit`\n  - `required`\n- composition:\n  - `extend`\n- output immutability:\n  - `readonly`\n  - `freeze`\n\nWhen to use these helpers:\n- `strip` at untrusted boundaries when extra keys should be ignored.\n- `passthrough` when preserving unknown extension keys is intentional.\n- `catchall` when extension keys are allowed but must still be typed.\n- `partial` for patch/update payloads.\n- `pick`/`omit` for endpoint-specific projections.\n- `required` when moving from partial input to strict internal shapes.\n\n## Full Integration Example\n\n```luau\nlocal schema = require(\"@eryx/schema\")\n\nlocal struct = require(\"@eryx/schema/struct\")\nlocal Payload = struct.strip(schema.table({\n\tid = schema.number():int(),\n\trole = schema.anyOf(\"admin\", \"member\"),\n\ttags = schema.optional(schema.array(schema.string())),\n}))\n\nlocal ok, result = Payload:parse({\n\tid = 42,\n\trole = \"admin\",\n\ttags = { \"ops\" },\n\textra = \"ignored\",\n})\n```\n\n## Notes and Conventions\n\n- Schema modifiers are immutable-style: chaining creates new schema objects.\n- Error messages are path-oriented for easier debugging of nested failures.\n- Favor small, reusable schema fragments and compose them.\n- Keep schemas close to your domain modules for discoverability and drift\n  prevention.\n"
    }
  ]
}