diff --git a/packages/taco/src/conditions/schemas/context.ts b/packages/taco/src/conditions/schemas/context.ts index 3c2f2a92..edfa17a4 100644 --- a/packages/taco/src/conditions/schemas/context.ts +++ b/packages/taco/src/conditions/schemas/context.ts @@ -6,7 +6,8 @@ import { plainStringSchema } from './common'; export const contextParamSchema = z.string().regex(CONTEXT_PARAM_REGEXP); -const paramSchema = z.union([plainStringSchema, z.boolean(), z.number()]); +// TODO: This is too broad, but it's a start +const paramSchema = z.union([plainStringSchema, z.boolean(), z.number().int().nonnegative()]); export const paramOrContextParamSchema: z.ZodSchema = z.union([ paramSchema, diff --git a/packages/taco/test/conditions/context.test.ts b/packages/taco/test/conditions/context.test.ts index e893766a..2e90bc50 100644 --- a/packages/taco/test/conditions/context.test.ts +++ b/packages/taco/test/conditions/context.test.ts @@ -523,10 +523,6 @@ describe('param or context param schema', () => { expect(paramOrContextParamSchema.safeParse(123).success).toBe(true); }); - it('accepts an floating number', () => { - expect(paramOrContextParamSchema.safeParse(123.4).success).toBe(true); - }); - it('accepts a string', () => { expect(paramOrContextParamSchema.safeParse('deadbeef').success).toBe(true); }); @@ -576,7 +572,7 @@ describe('param or context param schema', () => { 1, [ 2, - [true, [1.23, ':hi', '0xdeadbeef'], ':my_name_is', 1], + [true, [123, ':hi', '0xdeadbeef'], ':my_name_is', 1], ':slim_shady', false, ],