elysiajs / elysia

Ergonomic Framework for Humans
https://elysiajs.com
MIT License
9.23k stars 198 forks source link

Normalize disabled when additional properties is set to true #631

Closed m1212e closed 1 month ago

m1212e commented 2 months ago

Hi @SaltyAom,

at /src/utils.ts:273 /src/utils.ts:347

you check the following condition:

if (normalize && schema.additionalProperties === true)
            // @ts-ignore
            compiledValidator.Clean = cleaner

which I think should be the other way around: If normalization is enabled and the schema DOES NOT allow additionalProperties the cleaner should kick in, since then we need to clean out the disallowed fields. If I understand the code correctly, currently we check if normalization is enabled, and if so we only clean when the schema allows additionalProperties, which doesn't make sense since we actually want the additional properties to pass?