Updates to Providers Submit Endpoint Form#1074
Conversation
WalkthroughValidation 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
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
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
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.ukandorg.ukdomains, but the PR objectives specifically mention onlygov.ukdomain validation. Please confirm iforg.ukshould be included or if this should be restricted togov.ukonly.If only
gov.ukis 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
📒 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.
Description
Added validation for email and documentation URL.
What type of PR is this? (check all applicable)
Related Tickets & Documents
QA Instructions, Screenshots, Recordings
Before
After
Added/updated tests?
We encourage you to keep the code coverage percentage at 80% and above.
QA sign off
[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
Bug Fixes