Skip to content

[Bugfix] #8364, #8176 fix address validation #3644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

yuliiakaras
Copy link
Collaborator

@yuliiakaras yuliiakaras commented Apr 28, 2025

#8364
#8176

Summary by CodeRabbit

  • Bug Fixes

    • Adjusted validation for address input fields: increased maximum length for "house" from 4 to 10 characters and "entrance" from 2 to 3 characters.
    • Updated "entrance" field to accept only numeric input.
    • Simplified comment form validation by removing unnecessary pattern checks.
  • Documentation

    • Updated English and Ukrainian validation messages to reflect new input length constraints and improved error descriptions for address fields.
  • Style

    • Standardized error message keys and improved consistency across validation messages.

Copy link

coderabbitai bot commented Apr 28, 2025

Walkthrough

This update modifies validation rules and related error messages for address and comment input fields across several components and localization files. The maximum allowed length for "house" and "entrance" fields is increased, and pattern validation for the "entrance" field is updated to require numeric input. Error message keys and validation messages are aligned with these new constraints in both English and Ukrainian localization files. The Binotel link pattern and its related validation logic are removed, and the comment input field now uses only a maximum length validator, regardless of context.

Changes

File(s) Change Summary
src/app/ubs/shared/components/address-input/address-input.component.ts Increased max length for houseNumber (4→10) and entranceNumber (2→3), updated pattern for entranceNumber to numeric, added numericPattern property.
src/app/ubs/shared/components/ubs-input-error/ubs-input-error.component.ts
...component.spec.ts
Updated error key mappings, adjusted maxlength thresholds (house: 4→10, entrance: 2→3), replaced Binotel link pattern with numeric pattern for entrance validation, modified related test case.
src/app/ubs/ubs-admin/components/shared/components/comment-pop-up/comment-pop-up.component.ts Simplified form logic to always apply only the maxlength validator to the comment field, regardless of context.
src/assets/patterns/patterns.ts Removed binotelLinkPattern from exported patterns.
src/assets/i18n/ubs/en.json
src/assets/i18n/ubs/ua.json
src/assets/i18n/ubs-admin/en.json
src/assets/i18n/ubs-admin/ua.json
Updated validation messages: increased max lengths for house (4→10) and entrance (2→3), added/renamed error keys, and updated error texts in both English and Ukrainian.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AddressInputComponent
    participant UBSInputErrorComponent
    participant Patterns

    User->>AddressInputComponent: Enter house or entrance number
    AddressInputComponent->>Patterns: Get numeric/building pattern
    AddressInputComponent->>UBSInputErrorComponent: Validate input
    UBSInputErrorComponent->>Patterns: Use numeric pattern for entrance
    UBSInputErrorComponent-->>User: Show updated error message if invalid
Loading

Suggested reviewers

  • holus-bolus
  • hnativlyubomyr
  • Tadei-Mykola

Poem

In fields of forms where numbers grow,
The house and entrance now can show
More digits than they did before—
Ten for houses, three at the door!
Patterns pruned and errors neat,
The rabbit hops with nimble feet,
To celebrate this tidy feat! 🐇✨


📜 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 04f39a2 and c531573.

📒 Files selected for processing (9)
  • src/app/ubs/shared/components/address-input/address-input.component.ts (2 hunks)
  • src/app/ubs/shared/components/ubs-input-error/ubs-input-error.component.spec.ts (1 hunks)
  • src/app/ubs/shared/components/ubs-input-error/ubs-input-error.component.ts (3 hunks)
  • src/app/ubs/ubs-admin/components/shared/components/comment-pop-up/comment-pop-up.component.ts (1 hunks)
  • src/assets/i18n/ubs-admin/en.json (1 hunks)
  • src/assets/i18n/ubs-admin/ua.json (1 hunks)
  • src/assets/i18n/ubs/en.json (1 hunks)
  • src/assets/i18n/ubs/ua.json (1 hunks)
  • src/assets/patterns/patterns.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • src/assets/patterns/patterns.ts
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/app/ubs/shared/components/address-input/address-input.component.ts (2)
src/assets/patterns/patterns.ts (1)
  • Patterns (2-50)
src/app/ubs/shared/validators/empthy-or-valid.validator.ts (1)
  • emptyOrValid (3-20)
src/app/ubs/shared/components/ubs-input-error/ubs-input-error.component.ts (1)
src/assets/patterns/patterns.ts (1)
  • Patterns (2-50)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (18.x)
🔇 Additional comments (16)
src/assets/i18n/ubs-admin/en.json (1)

1018-1018: Validation constraint updated for entrance field length.

The maximum allowed length for the entrance field has been increased from 2 to 3 characters, making the validation message consistent with the form validation logic.

src/assets/i18n/ubs-admin/ua.json (1)

1016-1016: Validation constraint updated for entrance field length in Ukrainian localization.

The Ukrainian message for entrance field validation has been properly updated to allow 1-3 characters, maintaining consistency with the English version.

src/app/ubs/shared/components/ubs-input-error/ubs-input-error.component.spec.ts (1)

51-51: Test updated to match new validation constraint.

The test case for entrance field validation has been properly updated to use a requiredLength of 3 instead of 2, ensuring test accuracy with the new validation rules.

src/app/ubs/ubs-admin/components/shared/components/comment-pop-up/comment-pop-up.component.ts (1)

35-35: Simplified comment validation by removing link pattern validation.

The form initialization has been simplified to use only the maxLength validator, removing the conditional Binotel link pattern validation. This change improves code maintainability while addressing validation concerns mentioned in the bug report.

src/assets/i18n/ubs/ua.json (2)

14-14: Validation constraint updated for house field

The maximum length for house number has been increased from 4 to 10 characters, and the key has been renamed from "max-length-house-number" to "max-length-house". This change aligns with the validator updates in the address input component.


16-16: Validation constraint updated for entrance field

The maximum allowed length for the entrance field has been increased from 2 to 3 characters. This change aligns with the updated validators in the address input component.

src/assets/i18n/ubs/en.json (3)

10-10: New validation message for entrance field

A new validation message has been added for the numeric-only pattern validation of the entrance field. This aligns with the updated validation logic in the address input component.


13-13: Updated validation message for house field

The maximum length for house number has been increased from 4 to 10 characters, and the key has been renamed from "max-length-house-number" to "max-length-house". This matches the changes in the Ukrainian locale file.


15-15: Validation constraint updated for entrance field

The maximum allowed length for the entrance field has been increased from 2 to 3 characters. This change is consistent with the Ukrainian translation and the validator updates.

src/app/ubs/shared/components/address-input/address-input.component.ts (3)

71-72: Added numeric pattern for entrance field validation

A new readonly property numericPattern is introduced to use for entrance field validation, which will restrict input to numeric characters only. This provides a better user experience by enforcing only numbers in entrance fields.


272-275: Increased maximum length for house number

The maximum length for the house number field has been increased from 4 to 10 characters while maintaining the same pattern validation. This change allows for longer house numbers, addressing issue #8364 mentioned in the PR description.


276-280: Updated entrance field validation

The entrance field validation has been updated to:

  1. Increase the maximum length from 2 to 3 characters
  2. Change the pattern validation from buildingPattern to numericPattern

This change improves validation by ensuring entrance numbers contain only digits and allows for wider range of valid values.

src/app/ubs/shared/components/ubs-input-error/ubs-input-error.component.ts (4)

37-39: Updated error message key for house field validation

The error message key for house field validation has been renamed from "max-length-house-number" to "max-length-house" to maintain consistency with the localization files.


55-57: Added error message mapping for numeric-only validation

A new error message key "numericOnly" has been added and mapped to 'input-error.entrance-wrong'. This supports the new numeric-only validation for the entrance field.


115-117: Updated pattern validation for numeric input

The pattern validation check now includes a case for Patterns.numeric that returns the numeric-only error message. This replaces the removed binotelLinkPattern and aligns with the entrance field validation changes.


122-130: Updated maxlength validation thresholds

Two significant changes were made to the maxlength error message mapping:

  1. Line 124: Changed the entrance field maxlength from 2 to 3
  2. Line 128: Changed the house field maxlength from an implied 5 to 10

These changes align with the updated validators in the address input component and the corresponding localization strings.

✨ 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.
    • 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 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 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 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.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
50.0% Coverage on New Code (required ≥ 75%)

See analysis details on SonarQube Cloud

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.

1 participant