Skip to content

WEB-748: Improve email validation and fix translation namespace consi…#3180

Open
parth-sharma-10 wants to merge 1 commit intoopenMF:devfrom
parth-sharma-10:WEB-748-improve-email-validation
Open

WEB-748: Improve email validation and fix translation namespace consi…#3180
parth-sharma-10 wants to merge 1 commit intoopenMF:devfrom
parth-sharma-10:WEB-748-improve-email-validation

Conversation

@parth-sharma-10
Copy link
Contributor

@parth-sharma-10 parth-sharma-10 commented Feb 17, 2026

WEB-748
This PR improves validation reliability for the Email Address field in the Create Client → General Step.

The existing implementation relied on Angular’s default Validators.email, which permits loosely formatted email inputs. Validation has been strengthened to enforce stricter formatting standards and ensure better data quality.

Additionally, the translation namespace for the email validation message has been corrected to align with the application's established errors.* structure, ensuring consistent i18n behavior across the form.

Summary by CodeRabbit

  • New Features
    • Optional configurable email validation pattern can be provided at deployment to customize allowed email formats.
  • Bug Fixes
    • Email address is now required when creating a client.
    • Validation messaging clarified to distinguish missing vs. invalid email.
    • Email format validation strengthened to reduce false positives.
  • Documentation
    • README updated with configuration and example for external email validation.

@coderabbitai
Copy link

coderabbitai bot commented Feb 17, 2026

Warning

Rate limit exceeded

@parth-sharma-10 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 10 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'pre_merge_checks'
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • 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

Walkthrough

Email validation switched from Angular's built-in Validators.email to a configurable regex (environment.EXTERNAL_EMAIL_REGEX with fallback) applied to the emailAddress form control; template error checks and translation key updated. New runtime env keys and README docs added.

Changes

Cohort / File(s) Summary
Client component (template + logic)
src/app/clients/client-stepper/client-general-step/client-general-step.component.ts, src/app/clients/client-stepper/client-general-step/client-general-step.component.html
Replaced Validators.email with Validators.pattern(emailRegex) where emailRegex is taken from environment.EXTERNAL_EMAIL_REGEX or a default. Template condition changed from errors?.email to hasError('pattern') && value and error translation key updated.
Runtime env assets
src/assets/env.js, src/assets/env.template.js
Added EXTERNAL_EMAIL_REGEX property to the client-side runtime env object (window['env']) initialized to ''.
Angular environment configs
src/environments/environment.ts, src/environments/environment.prod.ts
Added EXTERNAL_EMAIL_REGEX property to exported environment objects (empty string default).
Documentation
README.md
Added "External Email Validation Configuration" section documenting EXTERNAL_EMAIL_REGEX, default fallback, example, and Docker Compose snippet.

Sequence Diagram(s)

sequenceDiagram
    participant Browser
    participant EnvJS as Runtime env (window['env'])
    participant Angular as App (environment.ts)
    participant Component as ClientForm
    Browser->>EnvJS: load env.js (EXTERNAL_EMAIL_REGEX)
    Browser->>Angular: bootstrap app (reads environment.EXTERNAL_EMAIL_REGEX or uses '')
    Angular->>Component: setClientForm() (derive emailRegex = environment.EXTERNAL_EMAIL_REGEX || DEFAULT)
    Component->>Component: apply Validators.pattern(emailRegex) to emailAddress
    Browser->>Component: user enters email
    Component->>Component: validate -> pattern check
    Component->>Browser: template shows error if hasError('pattern') && value
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • IOhacker
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: improving email validation with a stricter regex and fixing the translation namespace key from 'error.Email' to 'errors.Email'.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/app/clients/client-stepper/client-general-step/client-general-step.component.ts`:
- Around line 134-140: The emailAddress FormControl in
ClientGeneralStepComponent was made required (Validators.required) which changes
behavior; remove Validators.required so the control remains optional and keep
only the pattern validator so format is enforced only when a value is present,
or if requirement depends on client type add a conditional required validator
(e.g., add/remove Validators.required at runtime based on client type) instead
of a static required in the control definition.

Copy link
Contributor

@IOhacker IOhacker left a comment

Choose a reason for hiding this comment

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

The email must be optional

@parth-sharma-10 parth-sharma-10 force-pushed the WEB-748-improve-email-validation branch from 200636e to a1279ff Compare February 17, 2026 18:18
@parth-sharma-10
Copy link
Contributor Author

The email must be optional

@IOhacker I have updated the PR. The email is now optional.

@parth-sharma-10 parth-sharma-10 force-pushed the WEB-748-improve-email-validation branch from a1279ff to 6b6ada1 Compare February 17, 2026 19:00
@parth-sharma-10 parth-sharma-10 force-pushed the WEB-748-improve-email-validation branch from 6b6ada1 to 65be4bc Compare February 20, 2026 15:13
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: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@README.md`:
- Around line 382-385: The fenced code block containing the environment variable
declaration EXTERNAL_EMAIL_REGEX should include a language specifier to satisfy
markdownlint MD040; update the block opening from ``` to ```bash (or another
appropriate language like sh) so the snippet reads as a shell-style code block
and linter warnings are resolved.

In `@src/assets/env.template.js`:
- Around line 124-125: The new env.template.js entry for
window['env']['EXTERNAL_EMAIL_REGEX'] currently hardcodes an empty string,
preventing runtime substitution; change it to use the same envsubst placeholder
pattern as other keys (e.g., '$EXTERNAL_EMAIL_REGEX') so Docker/nginx envsubst
can inject the environment variable at deploy time and the app can read
EXTERNAL_EMAIL_REGEX from loadedEnv; update the
window['env']['EXTERNAL_EMAIL_REGEX'] assignment to mirror the placeholder style
used by window['env']['EXTERNAL_NATIONAL_ID_REGEX'] and other entries.

In `@src/environments/environment.prod.ts`:
- Line 19: Production environment value EXTERNAL_EMAIL_REGEX is hard-coded to an
empty string; update it to read the runtime-loaded value like the other entries
(use loadedEnv['EXTERNAL_EMAIL_REGEX'] || '') so it follows the bracket-notation
pattern used elsewhere (see externalNationalIdRegex for reference) and becomes
runtime-configurable.

In `@src/environments/environment.ts`:
- Line 22: EXTERNAL_EMAIL_REGEX is hardcoded to an empty string so it never
reads runtime values; update the environment export to read from loadedEnv by
changing EXTERNAL_EMAIL_REGEX to use loadedEnv.EXTERNAL_EMAIL_REGEX || '' so the
runtime-injected window.env value is used (match the pattern used by other keys
like externalNationalIdRegex).

- Keep email field optional
- Improve format validation using stricter regex
- Align translation namespace with errors.* structure

Fix: Make email optional and adjust validation logic
@parth-sharma-10 parth-sharma-10 force-pushed the WEB-748-improve-email-validation branch from 8df2b24 to f010ffa Compare February 20, 2026 15:26
@parth-sharma-10
Copy link
Contributor Author

Hi @IOhacker, I’ve addressed the comments. Could you please take another look when you get a chance? Thanks!

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.

2 participants