There’s a bug in checkDefault where it checks typeof field instead of typeof field.default. Because of this, nullable fields with a default value of "null" are incorrectly reported as invalid.
I verified the issue using a small reproduction script (repro_bug_standalone.js):
Before the fix: "null" defaults were incorrectly flagged.
After the fix: The check works correctly.
The corrected logic is:
if (
!field.notNull &&
typeof field.default === "string" &&
field.default.toLowerCase() === "null"
)
return true;