Skip to content

Possibility to get typescript error type in setGlobalMessage #964

Open
@vladshcherbin

Description

@vladshcherbin

Hey 👋

Wondering if it's somehow possible to get the correct typescript type from issue.type

setGlobalMessage((issue) => {
  switch (issue.type) {
    case 'min_length':
      // issue is of type MinLengthIssue so the issue.requirement is a number
      return `Please enter at least ${issue.requirement} characters`
    default:
      return issue.message
  }
}, 'en')

In the example above the type of issue.requirement is unknown

I've tried this way but it didn't work out:

image

I've also tried to find something like InferIssue<'min_length'> to pass error type there and it also didn't work out 😅

valibot - 1.0.0-beta.9

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions