Skip to content

exact-mirror creates undefined properties when Value.Clean doesn't #22

Open
@Lolotronop

Description

@Lolotronop

What version of Elysia is running?

1.3.4

What platform is your computer?

Linux 6.12.29 x86_64

What steps can reproduce the bug?

const type = t.Object({
  foo: t.Optional(t.String()),
});

console.log(createMirror(type, {})({})); // prints { foo: undefined }
console.log(Value.Clean(type, {})); // prints {} - an empty object

What is the expected behavior?

Optional fields don't get included at all in the output

What do you see instead?

Optional fields are included as undefined

Additional information

This is not a problem unless you try to add minProperties or maxProperties to an object, see elysiajs/elysia#1205
With Value.Clean no undefined properties get created, so min/maxPeroperties work correctly. With createMirror optional properties appear as undefined, which breaks compatibility with min/maxProperties

Have you try removing the node_modules and bun.lockb and try again yet?

doesn't matter

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions