You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The countWords function is invoked twice in the same validation block, causing redundant computation. Consider calling it once, storing the result in a local variable, and reusing it for both the min/max checks.
if(validation.minLength&&countWords(fieldValue)<validation.minLength){errors.push({field_id: `${question.id}`,message: `Must be at least ${validation.minLength} word(s)`,});}elseif(validation.maxLength&&countWords(fieldValue)>validation.maxLength){
The commented-out regex validation stub spans many lines without clear guidance. Either implement the pattern validation with tests or remove the block to keep the codebase clean.
// check regex pattern// if (validation.pattern) {// try {// const regex = new RegExp(validation.pattern);// if (!regex.test(fieldValue)) {// errors.push({// field_id: `${question.id}`,// message: `Value does not match the required pattern`,// });// }// } catch (regexError) {// errors.push({// field_id: `${question.id}`,// message: `Invalid validation pattern configured`,// });// }// }
-// if (validation.pattern) {+// Remove this commented block if pattern validation is no longer needed,+// or uncomment and integrate it back for runtime checks.
Suggestion importance[1-10]: 3
__
Why: Removing or re-enabling the commented pattern validation reduces dead code, but impact is minor cleanup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Enhancement
Description
Use word count for min/max validation
Introduce
countWordshelper functionUpdate error messages to mention words
Comment-out regex pattern validation stub
Changes walkthrough 📝
application_controller.ts
Switch string length validation to word countfunctions/src/controllers/application_controller.ts
countWordshelper to count words