New
Introducing React Bench, see how different models perform on React code

react-doctor/zod-v4-no-deprecated-schema-apis

Migrate deprecated Zod 4 schema APIs: z.object().strict() to z.strictObject(), z.nativeEnum to z.enum, z.record(value) to z.record(key, value), z.function().args().returns() to z.function({ input, output }).

Status
Active
Category
Architecture
Assessment
Evidence-required risk
Required evidence
source code, repository context
Default configuration
Enabled
Default severity
warn
Show technical metadata
Scope
All supported frameworks
Active when
always
Requirements
zod:4
Tags
migration-hint
Priority
40 (P3)
Source
oxlint-plugin-react-doctor
Rule set
oxlint-plugin-react-doctor 0.9.3 (prompt schema 2)
On this page

Validation prompt

Confirm the detector match and collect the required evidence before deciding whether an edit is warranted.

Fires only when an import binding resolves to zod (named, aliased, default, or namespace import) and the call/member matches one of: a deprecated top-level factory call z.nativeEnum/promise/ostring/onumber/oboolean/oarray; a .create() call on a dropped factory like z.string.create() or z.object.create(); a single-argument z.record(value); z.literal(Symbol(...)) or z.literal(Symbol.iterator); a z.function().args(...)/.returns(...) chain; z.object().strict()/strip()/passthrough()/nonstrict()/merge()/deepPartial() (including computed form z.object({})["strict"]()); z.number().safe(); .refine() whose SECOND argument is a function/arrow; or .Enum/.Values accessed off a z.enum() call. The detector requires a DIRECT method call on the factory call expression and resolves the import binding, so it does NOT fire on: z.strictObject({}), z.enum(Role), two-argument z.record(key, value), or z.function({ input, output }) (already Zod 4 forms); .strict()/.safe() called on a stored variable rather than inline on the factory call (e.g. const s = z.object({}); s.strict()); identically-named methods on non-zod objects (createValidator().object({}).strict()); dynamic bracket access with a variable key (schema.object({})[method]()); refine with an options object second arg ({ error: "..." }) or single-arg refine; and retained chains like z.number().int().min(0).max(100).

Evidence boundary

The diagnostic proves only that the detector’s modeled source pattern matched. It does not prove runtime impact, product intent, rendered failure, or that one remediation is correct.

Establish the environment, repository policy, exceptions, and required rendered or runtime evidence before deciding the occurrence.

Record one outcome:

  • Confirmed failure: The required evidence establishes the violation.
  • Rejected: A documented exception or false-positive predicate applies.
  • Needs evidence: Named evidence can still be collected.
  • Unavailable: Required evidence cannot be collected in this run.
  • Waived with evidence: An authorized, scoped exception applies to an established failure.
  • Observation: The review records an optional tradeoff without claiming a defect.

A waiver records its scope, authority, evidence, and review condition. It is not a pass or false positive.

Default severity is registry metadata. Use the occurrence’s JSON severity after repository configuration when ordering real findings.

Fix prompt

Apply this candidate correction only after the required evidence confirms the risk.

Replace the deprecated form with its Zod 4 equivalent: z.object({...}).strict() becomes z.strictObject({...}) (and .passthrough() to z.looseObject, .merge(b) to a.extend(b.shape) or spread); z.nativeEnum(X) and z.enum(["a"]).Enum/.Values become z.enum(X) reading members off the schema directly; z.string.create()/factory.create() drops .create() to just z.string(); single-arg z.record(valueSchema) gains an explicit key schema z.record(z.string(), valueSchema); z.function().args(z.string()).returns(z.number()) becomes z.function({ input: [z.string()], output: z.number() }); z.number().safe() uses .int() or explicit .min/.max bounds; z.literal(Symbol(...)) uses a dedicated symbol schema; and a function passed as refine's second argument moves to an options object z.string().refine(fn, { error: "..." }). See https://zod.dev/v4/changelog

Repository-wide copy prompt

Use this repository-wide prompt only after validating each occurrence. For one occurrence, use the guidance above.

Show repository-wide prompt

Fix every confirmed react-doctor/zod-v4-no-deprecated-schema-apis diagnostic in the current repository.

Required change:

  • Replace the deprecated form with its Zod 4 equivalent: z.object({...}).strict() becomes z.strictObject({...}) (and .passthrough() to z.looseObject, .merge(b) to a.extend(b.shape) or spread); z.nativeEnum(X) and z.enum(["a"]).Enum/.Values become z.enum(X) reading members off the schema directly; z.string.create()/factory.create() drops .create() to just z.string(); single-arg z.record(valueSchema) gains an explicit key schema z.record(z.string(), valueSchema); z.function().args(z.string()).returns(z.number()) becomes z.function({ input: [z.string()], output: z.number() }); z.number().safe() uses .int() or explicit .min/.max bounds; z.literal(Symbol(...)) uses a dedicated symbol schema; and a function passed as refine's second argument moves to an options object z.string().refine(fn, { error: "..." }). See https://zod.dev/v4/changelog.

Validation before editing:

Fires only when an import binding resolves to zod (named, aliased, default, or namespace import) and the call/member matches one of: a deprecated top-level factory call z.nativeEnum/promise/ostring/onumber/oboolean/oarray; a .create() call on a dropped factory like z.string.create() or z.object.create(); a single-argument z.record(value); z.literal(Symbol(...)) or z.literal(Symbol.iterator); a z.function().args(...)/.returns(...) chain; z.object().strict()/strip()/passthrough()/nonstrict()/merge()/deepPartial() (including computed form z.object({})["strict"]()); z.number().safe(); .refine() whose SECOND argument is a function/arrow; or .Enum/.Values accessed off a z.enum() call. The detector requires a DIRECT method call on the factory call expression and resolves the import binding, so it does NOT fire on: z.strictObject({}), z.enum(Role), two-argument z.record(key, value), or z.function({ input, output }) (already Zod 4 forms); .strict()/.safe() called on a stored variable rather than inline on the factory call (e.g. const s = z.object({}); s.strict()); identically-named methods on non-zod objects (createValidator().object({}).strict()); dynamic bracket access with a variable key (schema.object({})[method]()); refine with an options object second arg ({ error: "..." }) or single-arg refine; and retained chains like z.number().int().min(0).max(100).

Constraints:

  • Make the smallest change that fixes the root cause.
  • Preserve behavior and interfaces unrelated to this diagnostic.
  • Reuse existing project components, utilities, and conventions.
  • Adapt identifiers and framework details instead of copying blindly.
  • Do not disable the rule or suppress matching code.

Assessment:

  • Record detector evidence, applicability facts, assumptions, missing evidence, and the rule class for this occurrence.
  • Return one outcome: Confirmed failure, Rejected, Needs evidence, Unavailable, Waived with evidence, or Observation.
  • A waiver records the established failure, scope, authority, evidence, and review or expiry condition. It is not a pass or false positive.

Verification:

  • Run focused tests for the changed behavior.
  • Run React Doctor and confirm this diagnostic no longer appears from changed code.
  • Run an unfiltered scan of the affected scope before claiming no cross-category regression.
  • Report the files changed and any checks you could not run.