Skip to main content

Module schema_validation

Module schema_validation 

Source
Expand description

Callee-text classification for runtime schema / validation declarations.

Detects schema-library call sites in TypeScript/JavaScript (Zod, Yup, Valibot, io-ts, Superstruct) and Pydantic field functions in Python. Detection is callee-text only — no tree-sitter node-kind matching. call_expression/call nodes are already collected by the TS/JS/Python adapters; this module provides callee-text discrimination in CALL_DISPATCH at slot P4.

§Language support

  • TypeScript / JavaScript: Zod (z.object, z.string, z.enum), Yup (yup.object(), yup.string()), Valibot (v.object, v.pipe), Superstruct (s.object). Detected via the namespace prefix regex ^(z|yup|v|s)\.\w. Additionally, .safeParse( is matched as a Zod-specific validated-parse call.

  • Python: Pydantic Field(...), constr(...), conint(...) calls. Note: class Foo(BaseModel) is a class_definition already counted under class_hierarchy; only the call forms are captured here.

§Precision over recall

The TS/JS regex is anchored to the schema library namespace (z./yup./v./s.) rather than method names alone. This deliberately avoids bare .string()/.object() calls on arbitrary receivers — do not (re)introduce \.(object|string|array|…)\(, which floods the bucket. The trade-off: SomeSchema.parse(x) where the receiver name is arbitrary is not captured — receiver-type info SDIVI does not compute. Document this known recall gap.

§Pydantic class coverage

class Foo(BaseModel) is a class_definition node, already counted under class_hierarchy (M6). Python coverage here is intentionally partial: only call forms (Field(...), constr(...), conint(...)) are classified. class-validator decorators (@IsString()) belong to decorators (M36.1/M36.2); see docs/pattern-categories.md for the intentional split.

Constants§

NODE_KINDS
Tree-sitter node kinds for schema-validation patterns.

Functions§

matches_callee
Return true when text looks like a schema-validation callee for language.