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 validateNumberValue function uses if (validation.minValue && …) and if (validation.maxValue && …) which will skip validation when a bound is zero. Use explicit !== undefined or != null checks to ensure zero is handled correctly.
if(validation.minValue&&fieldValue<validation.minValue){errors.push({field_id: `${question.id}`,message: `Must be more than or equal to ${validation.minValue}`,});}if(validation.maxValue&&fieldValue>validation.maxValue){errors.push({field_id: `${question.id}`,message: `Must be less than or equal to ${validation.maxValue}`,});
validateStringValue compares raw string values to numeric minValue/maxValue, but should validate string length (e.g. minLength/maxLength). Otherwise non‐numeric strings will yield incorrect comparisons.
functionvalidateStringValue(fieldValue: string|any,question: Question){consterrors: {field_id: string;message: string;}[]=[];constvalidation=question.validationasStringValidation;// skip validation if not required and value is emptyif(validation.required!==true&&(fieldValue===undefined||fieldValue===""||fieldValue===null)){
In constructDataToSave, the new file-path rewrite is only inside a FILE type check. Verify that non-file fields are still being assigned to dataToSave as before.
The current checks skip zero boundary values because 0 is falsy. Use explicit undefined checks to ensure minValue or maxValue of zero are validated correctly.
+function isEmpty(value: any): boolean {+ return value === undefined || value === null || value === "";+}
// skip validation if not required and value is empty
-if (- validation.required !== true &&- (fieldValue === undefined || fieldValue === "" || fieldValue === null)-) {+if (!validation.required && isEmpty(fieldValue)) {
return errors;
}
Suggestion importance[1-10]: 5
__
Why: Extracting the repeated empty‐check logic into isEmpty improves readability and reduces duplication, but is a non‐critical refactor.
Low
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.
User description
PR Type
Bug fix, Enhancement
Description
Refactor validation functions: skip optional empties
Add typed error arrays and improved messages
Restrict file path rewrite to non-empty uploads
Configure Firestore ignoreUndefinedProperties
Fix sessionLogin user lookup collection
Changes walkthrough 📝
firebase.ts
Configure Firestore to ignore undefined propsfunctions/src/config/firebase.ts
db.settings({ ignoreUndefinedProperties: true })application_controller.ts
Enhance validation logic and error handlingfunctions/src/controllers/application_controller.ts
errorsarrays in all validatorsauth_controller.ts
Fix sessionLogin user document lookupfunctions/src/controllers/auth_controller.ts
"questions"to"users"