Skip to content

Conversation

razelos
Copy link

@razelos razelos commented Jun 8, 2024

Fix input field for Email not validating long TLD

After reviewing issue #33837 I changed the default email validation logic to accept TLDs up to 6 letters long. Also added a test to test the [email protected] email.

Fixes #33837

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • Bug Fixes

    • Updated email validation to support longer top-level domains (up to 6 characters).
  • Tests

    • Added a new test case to ensure email validation works with longer top-level domains (e.g., "[email protected]").

Copy link
Contributor

coderabbitai bot commented Jun 8, 2024

Important

Review skipped

Auto reviews are limited to specific labels.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The update addresses a bug in the InputWidgetV2 component, specifically enhancing the email validation regex to support longer top-level domains (TLDs). Additionally, a new test case in the derived.test.ts file ensures that emails with longer TLDs such as ".school" are correctly validated.

Changes

File Path Change Summary
app/client/src/widgets/InputWidgetV2/widget/derived.js Updated the email validation regex to allow for longer top-level domains.
app/client/src/widgets/InputWidgetV2/widget/derived.test.ts Added a test case to validate email input with longer TLDs, specifically testing the email "[email protected]".

Sequence Diagram(s)

Not applicable for these changes, as they primarily involve regex update and test case addition without significant control flow modifications.

Assessment against linked issues

Objective Addressed Explanation
Fix email validation for long TLDs (#33837)
Ensure test coverage for email validation with long TLDs (#33837)

Poem

In the land of code, a tweak was made,
To let long TLDs in emails parade.
From .com to .school, all now fit fine,
With regex updated, the stars align.
Bugs are squashed, and tests are bright,
Email validation now takes flight! 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c605677 and 16772d8.

Files selected for processing (2)
  • app/client/src/widgets/InputWidgetV2/widget/derived.js (1 hunks)
  • app/client/src/widgets/InputWidgetV2/widget/derived.test.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/client/src/widgets/InputWidgetV2/widget/derived.test.ts
Additional context used
Biome
app/client/src/widgets/InputWidgetV2/widget/derived.js

[error] 74-76: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause. (lint/correctness/noSwitchDeclarations)

The declaration is defined in this switch clause:

Unsafe fix: Wrap the declaration in a block.

Additional comments not posted (1)
app/client/src/widgets/InputWidgetV2/widget/derived.js (1)

75-75: Updated email validation regex to allow TLDs up to 6 characters.

* */
const emailRegex = new RegExp(
/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/,
/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/,
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrap the emailRegex declaration in a block to restrict its scope within the switch case.

- const emailRegex = new RegExp(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/);
+ {
  const emailRegex = new RegExp(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/);
  if (!emailRegex.test(value)) {
    return false;
  } else if (parsedRegex) {
    return parsedRegex.test(props.inputText);
  } else {
    return true;
  }
}
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.

Suggested change
/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/,
{
const emailRegex = new RegExp(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/);
if (!emailRegex.test(value)) {
return false;
} else if (parsedRegex) {
return parsedRegex.test(props.inputText);
} else {
return true;
}
}

Copy link
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 16772d8 and f680c9e.

Files selected for processing (1)
  • app/client/src/widgets/InputWidgetV2/widget/derived.test.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/client/src/widgets/InputWidgetV2/widget/derived.test.ts

Copy link

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Jun 15, 2024
Copy link

This PR has been closed because of inactivity.

@github-actions github-actions bot closed this Jun 22, 2024
@rahulbarwal
Copy link
Contributor

Reopening this. We will review and respond back.

@rahulbarwal rahulbarwal reopened this Jul 11, 2024
Copy link
Contributor

@rahulbarwal rahulbarwal left a comment

Choose a reason for hiding this comment

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

Hey @razelos
I went through the RFC 5322 specification:
Max allowed chars in TLD: 64.
Real-world max seen: XN--VERMGENSBERATUNG-PWB - 24 chars.
Additionally, this article from Wix gives examples of up to 10 chars.

If we just make it 6 then we are just reacting to the requirement. IMO we should make a long term solution with going ahead with 10 chars. Thoughts?

@rahulbarwal rahulbarwal added the Widgets Product This label groups issues related to widgets label Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stale Widgets Product This label groups issues related to widgets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Input field in Email mode validates incorrectly for long TLD

2 participants