Skip to content

Request: Warn when functions are passed unexpected arguments #1009

@arialaurel

Description

@arialaurel

Context

  • node version: 4.X
  • joi version: 9.0.4
  • environment (node, browser): node
  • used with (hapi, standalone, ...): hapi
  • any other relevant information:

What are you trying to achieve or the steps to reproduce ?

We had a developer, who after working with Joi.object for a couple validations assumed that Joi.string would also have a default behavior when passed an argument (this default behavior being to enforce a max). I realize this assumed behavior is not documented anywhere, but I think it would be nice if Joi.string and other similar validators that don't accept an argument would warn you of that if you pass them something.

const schema = {
  messageText: Joi.string(1024).required()
};

Which result you had ?

Joi.string silently accepted the argument, doing nothing with it.

What did you expect ?

A Joi error indicating that Joi.string does not accept any arguments

Metadata

Metadata

Assignees

Labels

featureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions