Skip to content

issue: custom field component for a type z.number().int() is ignored when I have z.number() present #117

@capaj

Description

@capaj

Version Number

1.6.4

Codesandbox/Expo snack

No response

Steps to reproduce

I have this mapping

export const JsonSchema = z.object({})
export const NullableDate = z.date().nullable()
export const CategoryId = z
 .number()
 .int()
 .refine((val) => val > 0)

const mapping = [
 [z.string(), TextField],
 [z.boolean(), CheckboxField],
 [z.number(), NumberField], // when I remove this line, component CategoryIdField renders for my schema
 [z.nativeEnum(AdminUserRoles), makeSelectFieldForEnum(AdminUserRoles)],
 [JsonSchema, JsonSchemaField] as const,
 [NullableDate, DateField] as const,
 [CategoryId, CategoryIdField] as const
] as const // 👈 `as const` is necessary

yet even when I use CategoryId in my zod schema, it is still rendering with NumberField

I will try to prepare a code sandbox

Expected behaviour

It should prefer the exact zod type rather than the generic z.number() field component

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions