diff --git a/packages/lexicon/src/validators/complex.ts b/packages/lexicon/src/validators/complex.ts index c4e5abc0b74..b3ea359c3ec 100644 --- a/packages/lexicon/src/validators/complex.ts +++ b/packages/lexicon/src/validators/complex.ts @@ -123,6 +123,21 @@ export function object( continue } const propDef = def.properties[key] + if (typeof value[key] === 'undefined' && !requiredProps.has(key)) { + // Fast path for non-required undefined props. + if ( + propDef.type === 'integer' || + propDef.type === 'boolean' || + propDef.type === 'string' + ) { + if (typeof propDef.default === 'undefined') { + continue + } + } else { + // Other types have no defaults. + continue + } + } const propPath = `${path}/${key}` const validated = validateOneOf(lexicons, propPath, propDef, value[key]) const propValue = validated.success ? validated.value : value[key]