Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const FormTemplateForm = ({
initialValues: buildInitialValues(initialValues, summitTZ),
validationSchema: yup.object({
code: requiredStringValidation(),
instructions: requiredStringValidation(),
opens_at: opensAtValidation(),
Comment on lines 52 to 55
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's locate the file and examine the context
cat -n src/pages/sponsors/sponsor-forms-list-page/components/form-template/form-template-form.js | head -60

Repository: fntechgit/summit-admin

Length of output: 2445


🏁 Script executed:

# Find FormikTextEditor implementation
rg -n "FormikTextEditor" -A 5 -B 2

Repository: fntechgit/summit-admin

Length of output: 15367


🏁 Script executed:

# Check requiredStringValidation implementation
cat -n src/utils/yup.js

Repository: fntechgit/summit-admin

Length of output: 6358


🏁 Script executed:

# Search for any rich-text or HTML validation patterns
rg -n "stripHtml|richText|required.*html|strip.*markup|empty.*html" -i

Repository: fntechgit/summit-admin

Length of output: 208


🏁 Script executed:

# Check FormikTextEditor export and imports
rg -n "export.*FormikTextEditor|import.*FormikTextEditor" -A 3 -B 1

Repository: fntechgit/summit-admin

Length of output: 4945


🏁 Script executed:

# Check FormikTextEditor full implementation
cat -n src/components/inputs/formik-text-editor.js

Repository: fntechgit/summit-admin

Length of output: 849


🏁 Script executed:

# Find and examine normalizeJoditEmpty
fd -n "normalizeJoditEmpty" -t f

Repository: fntechgit/summit-admin

Length of output: 296


🏁 Script executed:

# Check for TextEditorV3 implementation
rg -n "export.*TextEditorV3|import.*TextEditorV3" -A 5

Repository: fntechgit/summit-admin

Length of output: 12151


🏁 Script executed:

# Search for any field normalization or preprocessing in the form
rg -n "normalize|transform|setFieldValue|onChange" src/pages/sponsors/sponsor-forms-list-page/components/form-template/form-template-form.js

Repository: fntechgit/summit-admin

Length of output: 253


🏁 Script executed:

# Find normalizeJoditEmpty files and implementation
find . -type f -name "*normalizeJoditEmpty*"

Repository: fntechgit/summit-admin

Length of output: 186


🏁 Script executed:

# Search for normalizeJoditEmpty in the entire codebase
rg "normalizeJoditEmpty" -A 5 -B 2

Repository: fntechgit/summit-admin

Length of output: 2060


🏁 Script executed:

# Check if there's any validation or normalization of TextEditorV3 output
rg -n "trim|replace|normalize|stripHtml" src/components/inputs/formik-text-editor.js

Repository: fntechgit/summit-admin

Length of output: 48


🏁 Script executed:

# Check validation schema in other similar forms for comparison
rg -n "instructions.*validation|description.*validation" -B 2 -A 2

Repository: fntechgit/summit-admin

Length of output: 1357


🏁 Script executed:

# Check if normalizeJoditEmpty is imported or used anywhere in the codebase
rg "import.*normalizeJoditEmpty|normalizeJoditEmpty" --type js

Repository: fntechgit/summit-admin

Length of output: 729


🏁 Script executed:

# See the full test file to understand expected behavior
cat -n src/components/inputs/utils/__tests__/normalizeJoditEmpty.test.js

Repository: fntechgit/summit-admin

Length of output: 708


🏁 Script executed:

# Check if there are other examples of using normalizeJoditEmpty
rg "normalizeJoditEmpty" -l

Repository: fntechgit/summit-admin

Length of output: 182


Apply existing normalizeJoditEmpty utility to validate rich-text fields.

The instructions field uses requiredStringValidation() which only checks for non-empty strings. Rich-text editors like Jodit emit HTML markup for "empty" content (e.g., <p><br></p>), which passes validation despite being visually empty. The codebase already has a normalizeJoditEmpty utility that correctly strips HTML tags and converts empty markup to empty strings. Integrate it into the validation schema:

Recommended approach

Import normalizeJoditEmpty from src/components/inputs/utils/normalizeJoditEmpty.js and apply it as a Yup test:

+import normalizeJoditEmpty from "../../../../../components/inputs/utils/normalizeJoditEmpty";

   validationSchema: yup.object({
     code: requiredStringValidation(),
-    instructions: requiredStringValidation(),
+    instructions: requiredStringValidation().test(
+      "noEmptyMarkup",
+      T.translate("validation.required"),
+      (value) => normalizeJoditEmpty(value).length > 0
+    ),
     opens_at: opensAtValidation(),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
validationSchema: yup.object({
code: requiredStringValidation(),
instructions: requiredStringValidation(),
opens_at: opensAtValidation(),
import normalizeJoditEmpty from "../../../../../components/inputs/utils/normalizeJoditEmpty";
validationSchema: yup.object({
code: requiredStringValidation(),
instructions: requiredStringValidation().test(
"noEmptyMarkup",
T.translate("validation.required"),
(value) => normalizeJoditEmpty(value).length > 0
),
opens_at: opensAtValidation(),
🤖 Prompt for AI Agents
In
`@src/pages/sponsors/sponsor-forms-list-page/components/form-template/form-template-form.js`
around lines 52 - 55, The instructions field in the validationSchema currently
uses requiredStringValidation(), which accepts Jodit HTML like "<p><br></p>" as
non-empty; import the normalizeJoditEmpty utility and replace/apply it to the
instructions rule by adding a Yup test that runs normalizeJoditEmpty(value) and
ensures it returns a non-empty string (i.e., use the test to call
normalizeJoditEmpty and fail when it yields an empty string) while keeping other
validators (e.g., requiredStringValidation) as needed so validationSchema ->
instructions uses normalizeJoditEmpty to normalize Jodit content before
checking.

expires_at: yup
.date(T.translate("validation.date"))
Expand Down