Skip to content

Commit 7d94a7a

Browse files
authored
Merge pull request #908 from 0xthierry/fix/convert-elysia-boolean-string-to-boolean
fix: boolean-string converted to string
2 parents b1aae8e + 6257252 commit 7d94a7a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/type-system.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,11 @@ export const ElysiaType = {
397397
.Transform(
398398
t.Union(
399399
[
400+
t.Boolean(property),
400401
t.String({
401402
format: 'boolean',
402403
default: false
403404
}),
404-
t.Boolean(property)
405405
],
406406
property
407407
)

test/type-system/boolean-string.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ describe('TypeSystem - BooleanString', () => {
6363
expect(() => Value.Decode(schema, null)).toThrow(error)
6464
})
6565

66+
it('Convert', () => {
67+
expect(Value.Convert(t.BooleanString(), 'true')).toBe(true)
68+
expect(Value.Convert(t.BooleanString(), 'false')).toBe(false)
69+
})
70+
6671
it('Integrate', async () => {
6772
const app = new Elysia().get('/', ({ query }) => query, {
6873
query: t.Object({

0 commit comments

Comments
 (0)