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

Incorrect types for joi.expression and LanguageMessages #3064

Open
davidjamesstone opened this issue Feb 14, 2025 · 0 comments
Open

Incorrect types for joi.expression and LanguageMessages #3064

davidjamesstone opened this issue Feb 14, 2025 · 0 comments
Labels
documentation Non-code related changes

Comments

@davidjamesstone
Copy link

davidjamesstone commented Feb 14, 2025

Module version

17.13.3

What documentation problem did you notice?

joi.expression type documentation

According to the docs, the second optional argument options is the same as the options for joi.ref with an additional functions object. This isn't reflected in the .d.ts file here.

I think it should be something like:

expression(template: string, options?: ReferenceOptions & { functions: Record<string, function>})

LanguageMessages type documentation

LanguageMessages is typed as type LanguageMessages = Record<string, string | Record<string, string>>; but the record value could also be a joi.expression(), correct?

I'm using Joi like this below and it seems to be happy, although the types aren't.

import lowerFirst from 'lodash/lowerFirst.js'

export const messages: LanguageMessages = {
  'string.base': joi.expression('Enter {{lowerFirst(#label)}}', { functions: { lowerFirst }})
}

Before I submit a PR, do you agree the types are incorrect?

@davidjamesstone davidjamesstone added the documentation Non-code related changes label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Non-code related changes
Projects
None yet
Development

No branches or pull requests

1 participant