Skip to content

Conversation

@santipalenque
Copy link

@santipalenque santipalenque commented Jan 30, 2026

https://app.clickup.com/t/86b8b14h1

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Form templates now require an instructions field to be completed during creation and updates, ensuring complete template documentation.

✏️ Tip: You can customize this high-level summary in your review settings.

related to #738

@coderabbitai
Copy link

coderabbitai bot commented Jan 30, 2026

📝 Walkthrough

Walkthrough

A single validation requirement is added to the FormTemplateForm schema, making the "instructions" field mandatory. This enhances validation by ensuring the field must be provided during form submission.

Changes

Cohort / File(s) Summary
Form Validation Schema
src/pages/sponsors/sponsor-forms-list-page/components/form-template/form-template-form.js
Added required string field "instructions" to the FormTemplateForm validation schema, enforcing mandatory input for this field.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested reviewers

  • smarcet

Poem

🐰 A field now must be filled with care,
Instructions clear, beyond compare,
No empty forms shall slip on through,
Validation strong, forever true! 🌟

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'fix: sponsor forms crud validation' aligns with the main change of making the 'instructions' field mandatory in sponsor forms validation, though it is broad enough to encompass multiple validation changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/sponsor-forms-crud-validation

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@src/pages/sponsors/sponsor-forms-list-page/components/form-template/form-template-form.js`:
- Around line 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.

Comment on lines 52 to 55
validationSchema: yup.object({
code: requiredStringValidation(),
instructions: requiredStringValidation(),
opens_at: opensAtValidation(),
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.

Copy link

@smarcet smarcet left a comment

Choose a reason for hiding this comment

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

LGTM

@smarcet smarcet merged commit 0588bbc into master Feb 2, 2026
9 checks passed
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.

3 participants