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({