Skip to content

Support JS validation for confirmation fields targetting phone fields#2545

Merged
Crabcyborg merged 1 commit into
masterfrom
support_js_validation_for_phone_field_confirmation_fields
Oct 15, 2025
Merged

Support JS validation for confirmation fields targetting phone fields#2545
Crabcyborg merged 1 commit into
masterfrom
support_js_validation_for_phone_field_confirmation_fields

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 15, 2025

Walkthrough

A conditional was added in js/formidable.js within validateFieldValue to invoke confirmField for 'tel' fields when shouldCheckConfirmField(field, onSubmit) returns true. This extends the confirmation-validation flow to telephone inputs, affecting control flow and error handling for those fields only.

Changes

Cohort / File(s) Summary of changes
Validation: confirm check for tel fields
js/formidable.js
In validateFieldValue, added a branch: if field.type === 'tel' and shouldCheckConfirmField(field, onSubmit) is true, call confirmField(field, errors). No exports or public APIs changed.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant F as Form (validateFieldValue)
  participant C as shouldCheckConfirmField
  participant CF as confirmField
  participant E as errors

  U->>F: Input value for tel field
  F->>C: shouldCheckConfirmField(field, onSubmit)?
  C-->>F: true/false
  alt tel field AND check required
    F->>CF: confirmField(field, errors)
    CF-->>E: Append confirmation errors (if any)
  else Not applicable
    F-->>F: Continue existing validation
  end
  F-->>U: Validation result (with/without errors)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

action: needs qa

Suggested reviewers

  • garretlaxton

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly highlights the main change by stating the addition of JS validation support for confirmation fields targeting phone inputs, which directly reflects the core update in the pull request.
Description Check ✅ Passed The description’s reference to the related Pro repository pull request is directly relevant to this changeset and provides context for the update to JS confirmation validation for phone fields.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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 support_js_validation_for_phone_field_confirmation_fields

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@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: 0

🧹 Nitpick comments (1)
js/formidable.js (1)

350-352: LGTM! Confirmation validation for tel fields implemented correctly.

The implementation properly extends confirmation field validation to telephone inputs. The logic correctly:

  • Uses shouldCheckConfirmField to determine when validation should run (on submit or when editing the confirmation field itself)
  • Delegates to the existing confirmField function for consistent error handling
  • Works alongside pattern validation for tel fields (if a pattern is set)

Optional refinement for structural consistency: Consider creating a dedicated checkTelField function (similar to checkEmailField and checkPasswordField) to encapsulate tel-specific validation logic. This would improve consistency with how email and password fields handle confirmation:

function checkTelField( field, errors, onSubmit ) {
    if ( shouldCheckConfirmField( field, onSubmit ) ) {
        confirmField( field, errors );
    }
}

Then update the conditional chain around line 346:

 } else if ( field.pattern !== null ) {
     checkPatternField( field, errors );
+} else if ( field.type === 'tel' ) {
+    checkTelField( field, errors, onSubmit );
 }

-if ( 'tel' === field.type && shouldCheckConfirmField( field, onSubmit ) ) {
-    confirmField( field, errors );
-}

However, the current implementation works correctly and is perfectly acceptable.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c9111c6 and 6819bbe.

📒 Files selected for processing (1)
  • js/formidable.js (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
js/formidable.js (1)
stripe/js/frmstrp.js (1)
  • errors (233-233)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Run PHP Syntax inspection (8.3)
  • GitHub Check: Cypress
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: Cypress
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: Run PHP Syntax inspection (8.3)
  • GitHub Check: PHP 7.4 tests in WP trunk
  • GitHub Check: PHP 7.4 tests in WP trunk

@Crabcyborg Crabcyborg merged commit 42989e8 into master Oct 15, 2025
36 checks passed
@Crabcyborg Crabcyborg deleted the support_js_validation_for_phone_field_confirmation_fields branch October 15, 2025 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant