Skip to content

Conversation

@Lokendra-egov
Copy link

@Lokendra-egov Lokendra-egov commented Oct 15, 2025

Summary by CodeRabbit

  • New Features

    • Tenant-configurable mobile number validation using MDMS v2 applied on user create/update/patch; falls back to defaults when no config found.
    • Validation is dynamic (pattern, length, prefixes, activation) and returns clear, actionable errors.
  • Chores

    • Replaced static mobile-pattern annotations with runtime MDMS-v2 validation.
    • Added MDMS-v2 DTOs, config properties, a default validation name constant, and a Redis-backed cache for validation rules.

@coderabbitai
Copy link

coderabbitai bot commented Oct 15, 2025

Walkthrough

Adds MDMS v2 DTOs and a Redis-backed ValidationRules cache, introduces MobileNumberValidator that queries MDMS-v2 with defaults, injects it into UserController flows, removes mobile @Pattern constraints from request models, exposes a StringRedisTemplate bean, and adds MDMS-v2 and validation-related configuration/constants.

Changes

Cohort / File(s) Summary
MDMS v2 DTOs
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2Data.java, core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2Response.java, core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2SearchCriteria.java, core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2SearchRequest.java, core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/ValidationData.java, core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/ValidationRules.java
New Lombok/Jackson data models for MDMS-v2 requests/responses and validation rule payloads.
Mobile validation service
core-services/egov-user/src/main/java/org/egov/user/domain/service/MobileNumberValidator.java
New service that fetches validation rules from MDMS-v2 (uses state-level tenant), falls back to defaults, validates mobile numbers (min/max/pattern/allowed starts), logs extensively, and throws CustomException on violations.
Validation cache repository
core-services/egov-user/src/main/java/org/egov/user/repository/ValidationRulesCacheRepository.java
New Redis-backed repository caching per-tenant ValidationRules with TTL; provides get/cache/clear operations and JSON (de)serialization.
Controller integration
core-services/egov-user/src/main/java/org/egov/user/web/controller/UserController.java
Injects MobileNumberValidator via constructor and invokes it for primary/alternate mobile numbers in create/update/patch flows.
Request model constraints removed
core-services/egov-user/src/main/java/org/egov/user/web/contract/UserRequest.java, core-services/egov-user/src/main/java/org/egov/user/web/contract/UserSearchRequest.java
Removed @Pattern(regexp = UserServiceConstants.PATTERN_MOBILE) from mobileNumber and alternatemobilenumber fields.
Configuration & constants
core-services/egov-user/src/main/resources/application.properties, core-services/egov-user/src/main/java/org/egov/user/config/UserServiceConstants.java
Added MDMS-v2 properties (egov.mdms.v2.host, egov.mdms.v2.search.endpoint), egov.mobile.validation.schema.code, egov.validation.cache.ttl.seconds, and constant DEFAULT_MOBILE_VALIDATION_NAME.
Redis bean exposure
core-services/egov-user/src/main/java/org/egov/user/EgovUserApplication.java
Added a Spring bean method exposing StringRedisTemplate.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant UC as UserController
  participant MV as MobileNumberValidator
  participant CACHE as ValidationRulesCacheRepository
  participant MD as MDMS-v2
  participant US as UserService

  Client->>UC: Create/Update/Patch User (RequestInfo, user)
  UC->>MV: validateMobileNumber(mobileNumber, tenantId, RequestInfo)

  MV->>CACHE: getValidationRules(tenantKey)
  alt Cache hit
    CACHE-->>MV: ValidationRules
  else Cache miss
    MV->>MD: POST /mdms/v2/search (MdmsV2SearchRequest)
    MD-->>MV: MdmsV2Response
    MV->>MV: select active "defaultMobileValidation"
    MV->>CACHE: cacheValidationRules(tenantKey, rules)
  end

  MV->>MV: if rules null -> use default rules
  MV->>MV: validate length / pattern / allowed starts
  alt Violations
    MV-->>UC: throw CustomException(errors)
  else Valid
    MV-->>UC: return
  end

  UC->>US: proceed with business operation
  US-->>UC: result
  UC-->>Client: Response
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Pay special attention to MobileNumberValidator.fetchValidationRules: MDMS-v2 request/response mapping, tenant resolution, error handling, and fallback logic.
  • Review ValidationRulesCacheRepository: Redis key/namespace, TTL application to the hash, and JSON (de)serialization edge cases.
  • Verify UserController constructor changes and new validateMobileNumber call sites for exception propagation and test coverage.
  • Confirm application.properties keys and the new constant usage are consistent across code.

Poem

A rabbit reads the MDMS map,
Hops to cache, then makes a snap.
Rules found, or defaults step in,
Patterns checked with a whiskered grin.
Hoppity-hop — validations win 🥕

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title '[Add] mobile validation from master data' clearly and concisely describes the main change: adding mobile number validation functionality that retrieves configuration from master data management (MDMS-v2).
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 d67572b and 9f07749.

📒 Files selected for processing (1)
  • core-services/egov-user/src/main/java/org/egov/user/repository/ValidationRulesCacheRepository.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • core-services/egov-user/src/main/java/org/egov/user/repository/ValidationRulesCacheRepository.java

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

🧹 Nitpick comments (2)
core-services/egov-user/src/main/java/org/egov/user/domain/service/MobileNumberValidator.java (2)

121-130: Fix misleading comment and minor cleanup

  • The comment says “first 2 characters” but code splits on '.' to get state-level tenant. Update the comment for clarity.
-            // Extract state level tenant (first 2 characters)
+            // Extract state-level tenant (substring before '.'), e.g., "pb.amritsar" -> "pb"

23-25: Resilience and maintainability: DI, timeouts, and caching

  • Prefer constructor injection with final fields for immutability and testability; avoid field injection.
  • Ensure RestTemplate has connect/read timeouts; otherwise MDMS outages can stall requests. Alternatively, use a preconfigured bean with timeouts.
  • Consider caching MDMS rules per state-level tenant (short TTL) to avoid per-request MDMS calls and reduce latency.

Possible direction (illustrative):

  • Inject a preconfigured RestTemplate bean with timeouts.
  • Add a lightweight cache (Spring Cache or Caffeine) for rules by tenant (keyed by state-level tenantId).

I can draft a small cache-backed provider (e.g., ValidationRulesProvider with @Cacheable) if you want.

Also applies to: 26-34, 143-145, 159-166

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a575cd0 and 5cd3f67.

📒 Files selected for processing (11)
  • core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2Data.java (1 hunks)
  • core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2Response.java (1 hunks)
  • core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2SearchCriteria.java (1 hunks)
  • core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2SearchRequest.java (1 hunks)
  • core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/ValidationData.java (1 hunks)
  • core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/ValidationRules.java (1 hunks)
  • core-services/egov-user/src/main/java/org/egov/user/domain/service/MobileNumberValidator.java (1 hunks)
  • core-services/egov-user/src/main/java/org/egov/user/web/contract/UserRequest.java (1 hunks)
  • core-services/egov-user/src/main/java/org/egov/user/web/contract/UserSearchRequest.java (0 hunks)
  • core-services/egov-user/src/main/java/org/egov/user/web/controller/UserController.java (7 hunks)
  • core-services/egov-user/src/main/resources/application.properties (1 hunks)
💤 Files with no reviewable changes (1)
  • core-services/egov-user/src/main/java/org/egov/user/web/contract/UserSearchRequest.java
🧰 Additional context used
🧬 Code graph analysis (6)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2SearchCriteria.java (1)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2SearchRequest.java (1)
  • Data (10-21)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2SearchRequest.java (1)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2SearchCriteria.java (1)
  • Data (9-28)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/ValidationRules.java (2)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2Data.java (1)
  • Data (9-32)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/ValidationData.java (1)
  • Data (9-20)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2Data.java (3)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2Response.java (1)
  • Data (11-19)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/ValidationData.java (1)
  • Data (9-20)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/ValidationRules.java (1)
  • Data (11-37)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/ValidationData.java (3)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2Data.java (1)
  • Data (9-32)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2Response.java (1)
  • Data (11-19)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/ValidationRules.java (1)
  • Data (11-37)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2Response.java (5)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2Data.java (1)
  • Data (9-32)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2SearchCriteria.java (1)
  • Data (9-28)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2SearchRequest.java (1)
  • Data (10-21)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/ValidationData.java (1)
  • Data (9-20)
core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/ValidationRules.java (1)
  • Data (11-37)
🔇 Additional comments (9)
core-services/egov-user/src/main/resources/application.properties (1)

68-72: LGTM! MDMS v2 configuration properly added.

The new MDMS v2 configuration properties are well-structured and align with the mobile validation integration objective.

core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2Response.java (1)

11-18: LGTM! Standard response wrapper with proper annotations.

The DTO structure correctly wraps the MDMS v2 data list with appropriate Lombok and Jackson mappings.

core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2Data.java (1)

9-32: LGTM! Well-structured MDMS v2 data model.

The DTO properly represents MDMS v2 data entries with appropriate field mappings and nested ValidationData structure.

core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2SearchCriteria.java (1)

9-28: LGTM! Search criteria with sensible pagination defaults.

The DTO provides appropriate search parameters with reasonable default values for limit (1000) and offset (0).

core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/ValidationData.java (1)

9-20: LGTM! Clean validation data container.

The DTO appropriately wraps ValidationRules with a validation name identifier.

core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/MdmsV2SearchRequest.java (1)

10-21: LGTM! Request wrapper follows MDMS v2 API contract.

The DTO properly wraps search criteria and request info. The capital-case JSON property names ("MdmsCriteria", "RequestInfo") likely match the MDMS v2 API specification.

core-services/egov-user/src/main/java/org/egov/user/domain/model/mdmsv2/ValidationRules.java (1)

11-37: LGTM! Comprehensive validation rule structure.

The DTO provides a thorough set of validation constraints including pattern matching, length bounds, prefix/digit restrictions, and user-friendly error messages.

core-services/egov-user/src/main/java/org/egov/user/web/contract/UserRequest.java (1)

47-49: Mobile number validation enforced and handles null/empty correctly. MobileNumberValidator.validateMobileNumber is called in all create, update, and patch endpoints and explicitly skips null or empty values, ensuring validation before persistence.

core-services/egov-user/src/main/java/org/egov/user/web/controller/UserController.java (1)

84-86: Enforce header‐based gating on mobile validation

  • Wrap mobileNumberValidator.validateMobileNumber(...) in
    if (isMobileValidationRequired(headers)) { … } for:
    /users/_createnovalidate (lines 109–111)
    /users/_updatenovalidate (lines 173–175)
    /profile/_update (add @RequestHeader HttpHeaders headers and wrap lines 192–194)
  • For /citizen/_create, decide if it should also honor this gating (add HttpHeaders headers and wrap) or remain always-on by design.

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: 0

🧹 Nitpick comments (1)
core-services/egov-user/src/main/java/org/egov/user/web/controller/UserController.java (1)

83-87: Extract duplicate validation logic into a helper method.

The same validation pattern for both primary and alternate mobile numbers is repeated across four methods (createCitizen, createUserWithoutValidation, updateUserWithoutValidation, and patch). This violates the DRY principle and makes maintenance harder.

Apply this diff to extract the common validation logic:

+    /**
+     * Validates both primary and alternate mobile numbers using MDMS-v2 validation rules.
+     *
+     * @param primaryMobile primary mobile number
+     * @param alternateMobile alternate mobile number (can be null)
+     * @param tenantId tenant identifier
+     * @param requestInfo request metadata
+     */
+    private void validateMobileNumbers(String primaryMobile, String alternateMobile, 
+                                       String tenantId, org.egov.common.contract.request.RequestInfo requestInfo) {
+        mobileNumberValidator.validateMobileNumber(primaryMobile, tenantId, requestInfo);
+        mobileNumberValidator.validateMobileNumber(alternateMobile, tenantId, requestInfo);
+    }
+
     @PostMapping("/citizen/_create")
     public Object createCitizen(@RequestBody @Valid CreateUserRequest createUserRequest) {
         log.info("Received Citizen Registration Request  " + createUserRequest);
         User user = createUserRequest.toDomain(true);
 
-        // Validate mobile number using MDMS-v2
-        mobileNumberValidator.validateMobileNumber(user.getMobileNumber(), user.getTenantId(), createUserRequest.getRequestInfo());
-        mobileNumberValidator.validateMobileNumber(user.getAlternateMobileNumber(), user.getTenantId(), createUserRequest.getRequestInfo());
+        validateMobileNumbers(user.getMobileNumber(), user.getAlternateMobileNumber(), 
+                            user.getTenantId(), createUserRequest.getRequestInfo());
 
         user.setOtpValidationMandatory(IsValidationMandatory);

Repeat the same change pattern for createUserWithoutValidation, updateUserWithoutValidation, and patch methods.

Also applies to: 109-113, 174-178, 194-198

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5cd3f67 and c2b35ec.

📒 Files selected for processing (1)
  • core-services/egov-user/src/main/java/org/egov/user/web/controller/UserController.java (7 hunks)
🔇 Additional comments (2)
core-services/egov-user/src/main/java/org/egov/user/web/controller/UserController.java (2)

14-14: LGTM! Dependency injection properly implemented.

The MobileNumberValidator is correctly imported, declared as a field, and injected via the constructor following standard Spring DI patterns.

Also applies to: 50-50, 66-66, 69-69


86-86: Validation safely handles null/empty mobile numbers
StringUtils.isEmpty() returns true for null or empty strings, so validateMobileNumber() immediately returns.

for (MdmsV2Data mdmsData : response.getMdms()) {
if (mdmsData.getData() != null
&& Boolean.TRUE.equals(mdmsData.getIsActive())
&& "defaultMobileValidation".equals(mdmsData.getData().getValidationName())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Move "defaultMobileValidation" to constants

Copy link
Author

Choose a reason for hiding this comment

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

Resolved

.build();

log.info("Calling MDMS-v2 at: {}", url);
MdmsV2Response response = restTemplate.postForObject(url, searchRequest, MdmsV2Response.class);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should think about caching instead of making network call for each request

Copy link
Author

Choose a reason for hiding this comment

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

@talele08 We’re calling MDMS to fetch the rules. Shouldn’t the caching be handled at the MDMS level instead? MDMS can decide whether to retrieve the data from the database or the cache.

Choose a reason for hiding this comment

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

@talele08 The cache logic should be implemented at the MDMS service level. The MDMS service should read from the cache and return the response. If caching is implemented separately in the User Service, any changes made at the MDMS level will not be reflected.
Ultimately, since MDMS is responsible for data creation and updation, the caching /reset caching should be managed within the MDMS service itself.

@JsonProperty("rules")
private ValidationRules rules;

@JsonProperty("validationName")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is validationName required? If it's only for default validation, can't we just initialise a default ValidationRule object and keep re-using it

Copy link
Author

Choose a reason for hiding this comment

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

Currently, as per the data, this is required since there will be multiple active entries for this schema code. To fetch the correct rules, we need to check using both conditions (active and validationName).

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: 3

🧹 Nitpick comments (2)
core-services/egov-user/src/main/java/org/egov/user/domain/service/MobileNumberValidator.java (2)

144-149: Hard-coded limit in MDMS search criteria.

Line 147 hard-codes limit(1000). If the MDMS schema contains more than 1000 validation configurations, some will be missed. Additionally, fetching 1000 records when typically only one is needed is inefficient.

Consider either:

  1. Making the limit configurable via application properties
  2. Adding a filter in the MDMS query itself to retrieve only the specific validation configuration by name
  3. Implementing pagination if the MDMS API supports it
+    @Value("${egov.mdms.v2.search.limit:1000}")
+    private Integer mdmsSearchLimit;
+
     MdmsV2SearchCriteria searchCriteria = MdmsV2SearchCriteria.builder()
             .tenantId(stateLevelTenantId)
             .schemaCode(validationSchemaCode)
-            .limit(1000)
+            .limit(mdmsSearchLimit)
             .offset(0)
             .build();

175-179: Overly broad exception handling masks errors.

Lines 175-179 catch all exceptions and return null, which causes the code to fall back to default validation rules. While this provides resilience, it also masks genuine errors such as:

  • Network connectivity issues
  • MDMS service downtime
  • Authentication/authorization failures
  • Malformed MDMS responses

Consider logging the exception type and message to help with debugging and monitoring:

         } catch (Exception e) {
-            log.error("Error fetching validation rules from MDMS-v2", e);
+            log.error("Error fetching validation rules from MDMS-v2 for tenant {}: {} - {}", 
+                     tenantId, e.getClass().getSimpleName(), e.getMessage(), e);
             // Don't fail user creation if MDMS is down, just log the error
             return null;
         }

Additionally, consider emitting metrics or alerts when MDMS calls fail, so operations teams can detect and respond to issues.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c2b35ec and 784d416.

📒 Files selected for processing (2)
  • core-services/egov-user/src/main/java/org/egov/user/config/UserServiceConstants.java (1 hunks)
  • core-services/egov-user/src/main/java/org/egov/user/domain/service/MobileNumberValidator.java (1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: holashchand
Repo: egovernments/Digit-Core PR: 739
File: core-services/mdms-v2/src/main/java/org/egov/infra/mdms/producer/Producer.java:31-35
Timestamp: 2025-05-22T11:05:27.628Z
Learning: In the MDMS V2 service, tenant ID validation happens in the service and validator layers before reaching the Producer.push() method.
📚 Learning: 2025-05-22T11:05:27.628Z
Learnt from: holashchand
Repo: egovernments/Digit-Core PR: 739
File: core-services/mdms-v2/src/main/java/org/egov/infra/mdms/producer/Producer.java:31-35
Timestamp: 2025-05-22T11:05:27.628Z
Learning: In the MDMS V2 service, tenant ID validation happens in the service and validator layers before reaching the Producer.push() method.

Applied to files:

  • core-services/egov-user/src/main/java/org/egov/user/domain/service/MobileNumberValidator.java
📚 Learning: 2025-05-22T11:05:57.893Z
Learnt from: holashchand
Repo: egovernments/Digit-Core PR: 739
File: core-services/mdms-v2/src/main/java/org/egov/infra/mdms/repository/impl/SchemaDefinitionDbRepositoryImpl.java:70-77
Timestamp: 2025-05-22T11:05:57.893Z
Learning: In the MDMS V2 service, tenant ID validation is performed in the MultiStateInstanceUtil.replaceSchemaPlaceholder method, which checks that the tenant ID contains a dot and has sufficient length for schema extraction in a central instance environment.

Applied to files:

  • core-services/egov-user/src/main/java/org/egov/user/domain/service/MobileNumberValidator.java
  • core-services/egov-user/src/main/java/org/egov/user/config/UserServiceConstants.java
📚 Learning: 2025-05-22T11:05:27.628Z
Learnt from: holashchand
Repo: egovernments/Digit-Core PR: 739
File: core-services/mdms-v2/src/main/java/org/egov/infra/mdms/producer/Producer.java:31-35
Timestamp: 2025-05-22T11:05:27.628Z
Learning: In the MDMS V2 service, tenant ID validation happens elsewhere in the codebase before reaching the Producer.push() method.

Applied to files:

  • core-services/egov-user/src/main/java/org/egov/user/domain/service/MobileNumberValidator.java
🔇 Additional comments (4)
core-services/egov-user/src/main/java/org/egov/user/config/UserServiceConstants.java (2)

73-73: LGTM! New constant is well-defined.

The DEFAULT_MOBILE_VALIDATION_NAME constant is appropriately named and will serve as a clear fallback for MDMS v2-based mobile validation rules.


64-64: Disregard the original review comment.

The PATTERN_MOBILE constant is not obsolete—it serves as a critical fallback mechanism:

  • Line 60: Used when MDMS v2 validation rules are unavailable
  • Line 95: Fallback pattern when MDMS regex is invalid (PatternSyntaxException)
  • Line 119: Default pattern for ValidationRules initialization

The code design intentionally preserves this constant for resilience. Removing it would break the fallback validation path. The transition to MDMS v2 does not eliminate the need for this safety mechanism.

Likely an incorrect or invalid review comment.

core-services/egov-user/src/main/java/org/egov/user/domain/service/MobileNumberValidator.java (2)

84-103: Previous feedback addressed: invalid regex pattern handling.

The pattern validation now correctly handles PatternSyntaxException by logging a warning and falling back to the default pattern. This prevents invalid MDMS regex from causing a 500 error.


161-168: Client-side filtering is currently necessary due to API model limitations.

The MDMS-v2 API client model (MdmsV2SearchCriteria) only exposes four fields: tenantId, schemaCode, limit, and offset. There is no mechanism to pass filter criteria (like validationName or isActive) through the search request. While the server-side model (MdmsCriteriaV2) includes filter and isActive fields, these are not exposed by the client library's search criteria class.

The client-side iteration at lines 161-168 is not an optimization opportunity with the current API contract—it is a necessity. Eliminating it would require extending MdmsV2SearchCriteria to support filtering (e.g., adding a filters or filterMap field), which is outside the scope of this code change.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 784d416 and d67572b.

📒 Files selected for processing (4)
  • core-services/egov-user/src/main/java/org/egov/user/EgovUserApplication.java (2 hunks)
  • core-services/egov-user/src/main/java/org/egov/user/domain/service/MobileNumberValidator.java (1 hunks)
  • core-services/egov-user/src/main/java/org/egov/user/repository/ValidationRulesCacheRepository.java (1 hunks)
  • core-services/egov-user/src/main/resources/application.properties (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • core-services/egov-user/src/main/java/org/egov/user/domain/service/MobileNumberValidator.java
  • core-services/egov-user/src/main/resources/application.properties
🔇 Additional comments (1)
core-services/egov-user/src/main/java/org/egov/user/EgovUserApplication.java (1)

109-112: Bean wiring aligns with existing Redis setup.

Reusing the existing JedisConnectionFactory keeps all Redis access points consistent; looks good.

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