Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validating booleans behaves erratically #926

Open
fredericoo opened this issue Nov 27, 2024 · 1 comment
Open

Validating booleans behaves erratically #926

fredericoo opened this issue Nov 27, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@fredericoo
Copy link

fredericoo commented Nov 27, 2024

What version of Elysia is running?

1.1.15

What platform is your computer?

Darwin 23.6.0 arm64 arm

What steps can reproduce the bug?

import { treaty } from '@elysiajs/eden';
import { expect, test } from 'bun:test';
import Elysia, { t } from 'elysia';

test('accepts optional query params with optional number', async () => {
        const repro = new Elysia().get('/repro', () => 'works', {
            query: t.Object({ string: t.Optional(t.String()), boolean: t.Optional(t.Boolean()) }),
        });
        const api = treaty(repro);

        const { error } = await api.repro.get({ query: { string: 'asd' } });
        expect(error).toBeNull();
    });

What is the expected behavior?

The optional boolean would be optional

What do you see instead?

schema validation error

Additional information

This has been introduced in 1.1 with the new schema validation coercion feature.

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

yes

@fredericoo fredericoo added the bug Something isn't working label Nov 27, 2024
@fredericoo
Copy link
Author

#907 seems to fix it

SaltyAom added a commit that referenced this issue Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant