Skip to content

Commit

Permalink
fix: boolean-string converted to string
Browse files Browse the repository at this point in the history
  • Loading branch information
0xthierry committed Nov 3, 2024
1 parent e715e00 commit 6257252
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/type-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,11 @@ export const ElysiaType = {
.Transform(
t.Union(
[
t.Boolean(property),
t.String({
format: 'boolean',
default: false
}),
t.Boolean(property)
],
property
)
Expand Down
5 changes: 5 additions & 0 deletions test/type-system/boolean-string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ describe('TypeSystem - BooleanString', () => {
expect(() => Value.Decode(schema, null)).toThrow(error)
})

it('Convert', () => {
expect(Value.Convert(t.BooleanString(), 'true')).toBe(true)
expect(Value.Convert(t.BooleanString(), 'false')).toBe(false)
})

it('Integrate', async () => {
const app = new Elysia().get('/', ({ query }) => query, {
query: t.Object({
Expand Down

0 comments on commit 6257252

Please # to comment.