Skip to content

Conversation

@JaySoni1
Copy link
Contributor

@JaySoni1 JaySoni1 commented Feb 9, 2026

Changes Made :-

-Added minimum value validation (min=0) to prevent negative numbers in the Code Value Position field.

WEB-682

Before :-

image

After :-

image

Summary by CodeRabbit

  • Bug Fixes
    • Strengthened form validation for position fields to prevent invalid negative values and enforce required input constraints.

@coderabbitai
Copy link

coderabbitai bot commented Feb 9, 2026

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

Added validation constraints to the position field in the code values form, including a min="0" HTML attribute and corresponding Validators.min(0) rule to prevent negative values. Updated the field's initial value from 0 to an empty string.

Changes

Cohort / File(s) Summary
Position Field Validation
src/app/system/codes/view-code/view-code.component.html, src/app/system/codes/view-code/view-code.component.ts
Added min="0" attribute to position input element and expanded form validators from Validators.required to [Validators.required, Validators.min(0)]. Changed initial position value from 0 to empty string in form initialization.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~4 minutes

Possibly related PRs

  • openMF/web-app#2983: Both PRs add min="0" to number inputs and introduce Validators.min(0) for corresponding Angular form controls to prevent negative values.
  • openMF/web-app#2833: Both PRs apply a minimum-value constraint to a numeric form field by adding min attribute and Validators.min rule to prevent non-positive/negative inputs.

Suggested reviewers

  • alberto-art3ch
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding validation to prevent negative values in the code value position field, which aligns with the changes in both the HTML (min="0" attribute) and TypeScript (Validators.min(0)) implementations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/app/system/codes/view-code/view-code.component.html (1)

70-78: ⚠️ Potential issue | 🟠 Major

Missing mat-error for the new min validation, and existing error message references wrong field.

Two issues in this block:

  1. The min="0" HTML attribute is added, and Validators.min(0) is set in the TS, but there's no mat-error for the min validation error. Users who enter a negative value will see the field marked invalid with no error message explaining why.

  2. Line 75 uses 'labels.inputs.name' instead of 'labels.inputs.Position' — this is a copy-paste bug from the name field's error block (pre-existing, but directly relevant to this change area).

Proposed fix
                 `@if` (codeValues.at(i).controls.position.hasError('required')) {
                   <mat-error>
-                    {{ 'labels.inputs.name' | translate }} {{ 'labels.commons.is' | translate }}
+                    {{ 'labels.inputs.Position' | translate }} {{ 'labels.commons.is' | translate }}
                     <strong>{{ 'labels.commons.required' | translate }}</strong>
                   </mat-error>
                 }
+                `@if` (codeValues.at(i).controls.position.hasError('min')) {
+                  <mat-error>
+                    {{ 'labels.inputs.Position' | translate }}
+                    <strong>{{ 'labels.commons.must be 0 or greater' | translate }}</strong>
+                  </mat-error>
+                }

Copy link
Collaborator

@alberto-art3ch alberto-art3ch left a comment

Choose a reason for hiding this comment

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

LGTM

@alberto-art3ch alberto-art3ch merged commit de2f9eb into openMF:dev Feb 9, 2026
5 checks passed
@JaySoni1
Copy link
Contributor Author

JaySoni1 commented Feb 9, 2026

@alberto-art3ch Thank You for the review

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