Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vine Enum with nullable #70

Open
kevinmelo opened this issue Aug 8, 2024 · 2 comments
Open

Vine Enum with nullable #70

kevinmelo opened this issue Aug 8, 2024 · 2 comments

Comments

@kevinmelo
Copy link

kevinmelo commented Aug 8, 2024

Package version

latest

Describe the bug

When i validate using VineJs and one of the keys is a enum but can be null it's give me de following error:

TypeError: Cannot convert undefined or null to object at Function.values (<anonymous>) at _VineNativeEnum

with the following json:

{
   "object": "my_object",
   "entry": [
       {
           "id": "0",
           "time": 1723073445,
           "changes": [
               {
                   "field": "any_field",
                   "value": {
                       "event": "APPROVED",
                       "message_template_id": 12345678,
                       "message_template_name": "my_message_template",
                       "message_template_language": "pt-BR",
                       "reason": null
                   }
               }
           ]
       }
   ]
}

The Complete vine schema:

export default vine.compile(
    vine.object({
        object: vine.string(),
        entry: vine.array(
            vine.object({
                id: vine.string(),
                time: vine.number(),
                changes: vine.array(
                    vine.object({
                        field: vine.string(),
                        value: vine.object({
                            event: vine.enum(OTHER_ENUM),
                            message_template_id: vine.number(),
                            message_template_name: vine.string(),
                            message_template_language: vine.string(),
                            reason: vine.enum(MY_ENUM).nullable(),
                        }),
                    })
                ),
            })
        ),
    })
)

Where the erro occurs
reason: vine.enum(MY_ENUM).nullable(),

Reproduction repo

No response

@thetutlage
Copy link
Contributor

Can you please share the complete Vine schema

@kevinmelo
Copy link
Author

Can you please share the complete Vine schema

Sure, i update the first comment with the Vine Schema

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants