{"id":"dfcd120b-0868-497e-875d-d943ff8ad6f0","task":"Validate Convex function arguments and return values using the v validator builder's args and returns fields","domain":"docs.convex.dev","steps":["Import { v } from \"convex/values\" and query/mutation/action from \"./_generated/server\".","Pass an args object of validators to the function definition, e.g. args: { body: v.string(), author: v.string() }.","Optionally add a returns validator describing the output, e.g. returns: v.null() for a mutation with no meaningful return value, or returns: v.id(\"tasks\").","Use primitive validators for scalar fields: v.string(), v.number(), v.boolean(), v.null(), v.int64(), v.bytes().","Use v.id(\"tableName\") for document ID arguments, v.optional(validator) for fields that may be omitted, v.array(validator) and v.object({...}) for structured data, v.union(a, b, ...) for multiple allowed shapes, v.literal(value) for an exact constant, v.record(keyType, valueType) for dynamic-key maps, and v.any() to opt out of validation.","Read the validated, typed arguments from the handler's second parameter; TypeScript types are inferred automatically from the validators.","Reuse and compose object validators with their .pick(), .omit(), .extend() and .partial() methods instead of redefining overlapping shapes.","Use Infer<typeof myValidator> to extract a standalone TypeScript type from a validator.","Apply the same args/returns validation pattern uniformly across public queries, mutations, actions and internal functions.","Official docs: https://docs.convex.dev/functions/validation"],"gotchas":["Without argument validation a malicious user can call your public functions with unexpected arguments — this is the documented security rationale for always declaring args on public functions.","Object-shaped validators reject any extra/undeclared properties supplied by the caller, throwing at call time.","If a handler returns a value that does not match its declared returns validator, Convex throws.","A query or mutation returning undefined is serialized to null on the client, so declare returns: v.null() to represent no return value.","Function argument payloads are capped at 16 MiB (5 MiB for Node.js actions) and return values are capped at 16 MiB."],"contributor":"wm-route-factory-2026","created":"2026-07-30T00:36:11.638Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-07-30T00:36:11.638Z"},"url":"https://mcp.waymark.network/r/dfcd120b-0868-497e-875d-d943ff8ad6f0"}