Skip to content

feat: support array and object input with messageParams and cause (#117) - #173

Closed
Ankitraj-sharma wants to merge 2 commits into
fastify:mainfrom
Ankitraj-sharma:feat/strict-param-validation
Closed

Ankitraj-sharma wants to merge 2 commits into
fastify:mainfrom
Ankitraj-sharma:feat/strict-param-validation

Conversation

@Ankitraj-sharma

Copy link
Copy Markdown

Summary

Closes #117.

This PR improves parameter handling for FastifyError instantiation as discussed in #117:

  1. Array input support: Allows passing an array of parameters to format strings with multiple specifiers (e.g. new CustomError(['foo', 'bar'])).
  2. Object input support: Implements the proposal to allow passing an object containing { messageParams, cause } directly (e.g. new CustomError({ messageParams: ['foo', 'bar'], cause: new Error('...') })).
  3. Format specifier counting: Added helper countFormatSpecifiers to determine expected formatting arguments while respecting escaped %% specifiers.
  4. Backward compatibility: Preserves existing variable arguments and options patterns without breaking existing tests or consumers.

Testing

  • Added unit tests for array of parameters.
  • Added unit tests for object input with messageParams and cause.
  • Added unit tests for object input with only cause when format parameters exist.
  • All 32 unit tests pass.

@gurgunday

gurgunday commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Hi, thanks for the PR but we currently have #151 which is already under review

@gurgunday gurgunday closed this Sep 30, 2026
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

Successfully merging this pull request may close these issues.

Strict amount of parameters, change input to array or object

2 participants