Skip to content

Updates to Providers Submit Endpoint Form#1074

Merged
feba-rajan merged 3 commits into
mainfrom
validation/submit-endpoint-form
Jul 15, 2025
Merged

Updates to Providers Submit Endpoint Form#1074
feba-rajan merged 3 commits into
mainfrom
validation/submit-endpoint-form

Conversation

@feba-rajan
Copy link
Copy Markdown
Contributor

@feba-rajan feba-rajan commented Jul 14, 2025

Description

Added validation for email and documentation URL.

  • Email address - must be a gov.uk domain
  • Documentation URL - is a webpage and doesn't contain other content and it is on a gov.uk domain

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Related Tickets & Documents

QA Instructions, Screenshots, Recordings

Before

Screenshot 2025-07-14 at 11 53 53

After

Screenshot 2025-07-14 at 11 54 42 Screenshot 2025-07-14 at 11 52 18

Added/updated tests?

We encourage you to keep the code coverage percentage at 80% and above.

  • Yes
  • No, and this is why: Please replace this line with details on why tests have not been included
  • I need help with writing tests

QA sign off

  • Code has been checked and approved
  • Design has been checked and approved
  • Product and business logic has been checked and proved

[optional] Are there any post-deployment tasks we need to perform?

[optional] Are there any dependencies on other PRs or Work?

Summary by CodeRabbit

  • New Features

    • Improved validation for email fields to ensure only valid gov.uk or org.uk email addresses are accepted.
    • Enhanced documentation URL validation to require links to gov.uk or org.uk webpages, excluding file links such as .csv, .json, and other specified formats.
  • Bug Fixes

    • Updated validation error messages to provide clearer and more specific guidance for email, endpoint URL, and documentation URL fields.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 14, 2025

Walkthrough

Validation logic and messaging were updated for email and documentation URL fields. New validators were introduced to enforce stricter rules for gov.uk email addresses and documentation URLs, and related validation messages were made more specific. Corresponding test expectations were updated to match the refined error messages.

Changes

File(s) Change Summary
src/filters/validationMessageLookup.js Added format key to email validation messages; refined format message for documentation-url to specify gov.uk webpage.
src/routes/form-wizard/endpoint-submission-form/fields.js Updated field validation: email now uses validEmail for format; documentation-url uses validDocumentationUrl validator.
src/utils/validators.js Added validDocumentationUrl and validEmail functions for stricter validation of documentation URLs and emails.
test/unit/views/submit/dataset-details.test.js Updated test to expect the new, more specific documentation-url format validation message.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Form
    participant Validators

    User->>Form: Submit email and documentation-url fields
    Form->>Validators: validEmail(email)
    Validators-->>Form: true/false
    Form->>Validators: validDocumentationUrl(url)
    Validators-->>Form: true/false
    Form-->>User: Show specific validation messages if invalid
Loading

Possibly related PRs

  • Check Too: Update validation messages #777: Also modifies validation messages in src/filters/validationMessageLookup.js, including updates to the endpoint-url field's format message, indicating overlap in validation context.

Poem

A rabbit hopped through fields of code,
With emails checked for gov.uk abode.
URLs now stricter, no files allowed,
Only webpages on domains that make us proud.
Tests now match what users see—
Validation clear as can be!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35b7805 and 3bca927.

📒 Files selected for processing (1)
  • src/utils/validators.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/utils/validators.js
⏰ 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). (1)
  • GitHub Check: run-tests / test
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 using 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 14, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 66.36% 5965 / 8988
🔵 Statements 66.36% 5965 / 8988
🔵 Functions 64.54% 253 / 392
🔵 Branches 80.54% 770 / 956
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/filters/validationMessageLookup.js 100% 100% 100% 100%
src/routes/form-wizard/endpoint-submission-form/fields.js 0% 0% 0% 0% 1-41
src/utils/validators.js 44% 100% 33.33% 44% 12-25, 28-29
Generated in workflow #1114 for commit 3bca927 by the Vitest Coverage Report Action

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)
src/utils/validators.js (1)

11-25: Verify domain requirements: org.uk inclusion may not align with PR objectives.

The function allows both gov.uk and org.uk domains, but the PR objectives specifically mention only gov.uk domain validation. Please confirm if org.uk should be included or if this should be restricted to gov.uk only.

If only gov.uk is required, apply this diff:

-    if (!url.hostname.toLowerCase().endsWith('gov.uk') && !url.hostname.toLowerCase().endsWith('org.uk')) return false
+    if (!url.hostname.toLowerCase().endsWith('gov.uk')) return false
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 20c220b and 98a010f.

📒 Files selected for processing (4)
  • src/filters/validationMessageLookup.js (2 hunks)
  • src/routes/form-wizard/endpoint-submission-form/fields.js (3 hunks)
  • src/utils/validators.js (1 hunks)
  • test/unit/views/submit/dataset-details.test.js (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
test/unit/views/submit/dataset-details.test.js (6)
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#644
File: test/unit/util.test.js:72-74
Timestamp: 2024-11-13T14:25:37.041Z
Learning: In `test/unit/util.test.js`, avoid using ISO 8601 date strings (e.g., `'2024-05-15T00:00:00.000Z'`) in tests, as they cause issues with daylight saving. Instead, use date strings like `'Tue, 15 May 2024 00:00:00'`.
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#609
File: test/unit/noErrorsPage.test.js:68-68
Timestamp: 2024-11-12T10:54:09.485Z
Learning: In `test/unit/noErrorsPage.test.js`, avoid using `prettifyColumnName` for column headers because the table can contain spec fields, as requested by Alex.
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#593
File: test/unit/lpaDetailsController.test.js:20-20
Timestamp: 2024-10-29T15:06:42.432Z
Learning: The function `initDatasetSlugToReadableNameFilter()` includes its own error handling, so additional try-catch blocks around it in test files are unnecessary.
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#593
File: index.js:20-20
Timestamp: 2024-10-29T14:58:22.843Z
Learning: The function `initDatasetSlugToReadableNameFilter()` in `src/utils/datasetSlugToReadableName.js` already includes appropriate error handling and logging.
Learnt from: rosado
PR: digital-land/submit#657
File: test/unit/middleware/issueDetails.middleware.test.js:43-43
Timestamp: 2024-11-14T16:38:49.883Z
Learning: In `test/unit/middleware/issueDetails.middleware.test.js`, template params are verified with a schema, so it's acceptable for the test expectations to use primitive values while the test input uses an object for `issueEntitiesCount`.
Learnt from: GeorgeGoodall-GovUk
PR: digital-land/submit#510
File: test/unit/middleware/datasetOverview.middleware.test.js:1-3
Timestamp: 2024-10-21T08:57:17.338Z
Learning: Tests for `pullOutDatasetSpecification` have been moved to `common.middleware.test`.
🧬 Code Graph Analysis (1)
src/routes/form-wizard/endpoint-submission-form/fields.js (1)
src/utils/validators.js (4)
  • validEmail (27-29)
  • validEmail (27-29)
  • validDocumentationUrl (11-25)
  • validDocumentationUrl (11-25)
⏰ 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). (2)
  • GitHub Check: test
  • GitHub Check: run-tests / test
🔇 Additional comments (7)
src/utils/validators.js (1)

27-29: LGTM! Email validation correctly enforces gov.uk domain.

The regex pattern properly validates email addresses with gov.uk domains and handles case-insensitivity and whitespace trimming appropriately.

test/unit/views/submit/dataset-details.test.js (1)

113-113: LGTM! Test expectation correctly updated for enhanced validation.

The updated error message properly reflects the new validation requirements for gov.uk domain and webpage-only URLs.

src/filters/validationMessageLookup.js (2)

44-44: LGTM! Clear and specific validation message for gov.uk email requirement.

The new format message clearly communicates the gov.uk domain requirement to users.


56-56: LGTM! Comprehensive validation message explains domain and file type restrictions.

The updated message effectively communicates both the gov.uk domain requirement and the webpage-only restriction with helpful examples.

src/routes/form-wizard/endpoint-submission-form/fields.js (3)

2-2: LGTM! Proper import of new validators.

The import statement correctly includes the new validation functions.


17-18: LGTM! Email field validation properly enhanced.

The email field now validates both standard email format and gov.uk domain requirement, maintaining existing validation whilst adding the new restriction.


34-34: LGTM! Documentation URL validation correctly upgraded.

The field now uses the enhanced validator that enforces gov.uk domain and webpage-only requirements.

Comment thread src/utils/validators.js Outdated
@feba-rajan feba-rajan merged commit 94e933c into main Jul 15, 2025
5 checks passed
@feba-rajan feba-rajan deleted the validation/submit-endpoint-form branch July 15, 2025 13:10
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