feat(inject-params): add required parameter validation and error handling for injectParams#670
feat(inject-params): add required parameter validation and error handling for injectParams#670
Conversation
…dling Introduce `required` option to enforce the presence of parameters in `injectParams`. Throws an error if the required parameter is missing. Includes updated typings, logic, and documentation improvements.
…for missing parameters Introduce `required` option to enforce the presence of query parameters in `injectQueryParams`. Throws an error if the required parameter is not provided. Includes updated typings, logic, documentation, and overloads for stricter parameter validation.
…meters with error handling Implement `required` option for `injectQueryParams.array` to enforce the presence of array query parameters. Includes stricter typings, new test cases, and error handling for missing required parameters.
Introduce test cases for required parameter handling in `injectParams`. Verify error handling when a required parameter is missing and successful resolution when it is present. Includes new test component `RequiredParamComponent`.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
View your CI Pipeline Execution ↗ for commit 24a1d64
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Code Review
This pull request introduces a new "required" option for injectParams and injectQueryParams functions, enhancing parameter validation by throwing an error if a required parameter is missing. The changes include adding the RequiredOptions type, updating the core logic to check for missing required parameters, and providing appropriate error messages. New test cases have been added to cover scenarios where required parameters are both present and missing, ensuring the feature works as expected. The type overloads have also been updated to reflect the non-nullable return type when required: true is used.
| if (!param) { | ||
| if (required) { | ||
| throw missingRequiredParamError( | ||
| keyOrParamsTransform as string | undefined, |
There was a problem hiding this comment.
In this context, keyOrParamsTransform is guaranteed to be a string because the preceding if conditions handle undefined and function types. The as string | undefined assertion is therefore redundant and can be simplified to keyOrParamsTransform.
| keyOrParamsTransform as string | undefined, | |
| keyOrParamsTransform, |
| if (!param) { | ||
| if (required) { | ||
| throw missingRequiredParamError( | ||
| keyOrParamsTransform as string | undefined, |
There was a problem hiding this comment.
Similar to the inject-params.ts file, keyOrParamsTransform is guaranteed to be a string at this point in the execution flow. The as string | undefined assertion is redundant and can be simplified to keyOrParamsTransform.
| keyOrParamsTransform as string | undefined, | |
| keyOrParamsTransform, |
| if (param.length < 1) { | ||
| if (required) { | ||
| throw missingRequiredParamError( | ||
| keyOrParamsTransform as string | undefined, |
No description provided.