{
  "id": "fn-core-check",
  "dataComponent": "core",
  "heading": {
    "title": "check",
    "badges": ["Core", "Schema", "TypeCheck"]
  },
  "synopsis": "Checks whether a value matches a given schema or type. This function is a flexible, non-throwing way to validate primitives, arrays, keyed objects, or deeply nested data structures. Use check to defend against unexpected or malformed input, verify outputs in tests, or enforce schema contracts at runtime. The check is recursive and forgiving of extra keys in objects: it only enforces fields you list in the schema.",
  "codeBlocks": [
    "# 1) Checking primitives\nsput( check(\"int\", 42) )             # => true\nsput( check(\"string\", 42) )          # => false\n\n# 2) Checking arrays of a type\nnums = [1,2,3]\nsput( check([\"int\"], nums) )         # => true\nwords = [\"a\", \"b\"]\nsput( check([\"string\"], words) )    # => true\n\n# 3) Validating keyed objects\nperson = [ name:\"Alice\", age:30 ]\nschema = [ name:\"string\", age:\"int\" ]\nsput( check(schema, person) )         # => true\n\n# 4) Arrays of objects (nested)\npeople = [ [ name:\"A\", age:1 ], [ name:\"B\", age:2 ] ]\nschema = [ [ name:\"string\", age:\"int\" ] ]\nsput( check(schema, people) )         # => true\n\n# 5) Missing or mismatched keys\nsput( check(schema, [ [ name:\"X\" ] ]) )   # => false\n"
  ],
  "notes": [
    "The schema can be a primitive type string (\"int\", \"float\", \"string\", etc.), a single-element array (e.g. [\"int\"] for IntArray), a keyed array (object shape), or an array of object schemas (for arrays of objects).",
    "check is recursive and validates every element and field as deeply as needed.",
    "For keyed objects, only the keys listed in the schema are required. Extra keys in the value are ignored.",
    "Always returns Bool(true) or Bool(false). Never throws for mismatches; the only error case is calling with the wrong number of arguments.",
    "Common uses: input validation (e.g. after decoding JSON), defending API boundaries, writing robust tests, or enforcing structure in scripts.",
    "No partial or placeholder usage: check always expects exactly two arguments—the schema and the value."
  ]
}
