From 6257252347f6bda0d4a0f0a03cf87e0f18b7876e Mon Sep 17 00:00:00 2001 From: Thierry Date: Sun, 3 Nov 2024 20:24:52 -0300 Subject: [PATCH] fix: boolean-string converted to string --- src/type-system.ts | 2 +- test/type-system/boolean-string.test.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/type-system.ts b/src/type-system.ts index 1cdbed63..51926dcf 100644 --- a/src/type-system.ts +++ b/src/type-system.ts @@ -397,11 +397,11 @@ export const ElysiaType = { .Transform( t.Union( [ + t.Boolean(property), t.String({ format: 'boolean', default: false }), - t.Boolean(property) ], property ) diff --git a/test/type-system/boolean-string.test.ts b/test/type-system/boolean-string.test.ts index e2ab301c..bea1cf55 100644 --- a/test/type-system/boolean-string.test.ts +++ b/test/type-system/boolean-string.test.ts @@ -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({