Skip to content

[NAE-2435] Enumeration field with no choices does not properly handle validation#328

Merged
machacjozef merged 3 commits into
release/7.0.0-rev10from
NAE-2435
May 11, 2026
Merged

[NAE-2435] Enumeration field with no choices does not properly handle validation#328
machacjozef merged 3 commits into
release/7.0.0-rev10from
NAE-2435

Conversation

@renczesstefan
Copy link
Copy Markdown
Member

@renczesstefan renczesstefan commented May 11, 2026

Description

Fixes NAE-2435

Dependencies

No new dependencies were introduced

Third party dependencies

No new dependencies were introduced

Blocking Pull requests

There are no dependencies on other PR

How Has Been This Tested?

This was tested manually and with unit tests.

Test Configuration

Name Tested on
OS macOS Tahoe 26.3
Runtime Node 20.17.0
Dependency Manager NPM 10.8.2
Framework version Angular 13.3.1
Run parameters
Other configuration

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes have been checked, personally or remotely, with @machacjozef @timbez
  • I have commented my code, particularly in hard-to-understand areas
  • I have resolved all conflicts with the target branch of the PR
  • I have updated and synced my code with the target branch
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes:
    • Lint test
    • Unit tests
    • Integration tests
  • I have checked my contribution with code analysis tools:
  • I have made corresponding changes to the documentation:
    • Developer documentation
    • User Guides
    • Migration Guides

Summary by CodeRabbit

  • Bug Fixes
    • Improved enumeration field validation: empty, null, or undefined values now pass validation; if the available choices are missing or empty a validation error is returned; non-empty values that do not match any available option correctly report an invalid-value error.

Review Change Stack

… validation

- refactore checkKey function in enumeration-field.ts
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: df35a98e-7153-43f3-929a-0ddf05e0d6bf

📥 Commits

Reviewing files that changed from the base of the PR and between e2fd048 and 969a6cd.

📒 Files selected for processing (1)
  • projects/netgrif-components-core/src/lib/data-fields/enumeration-field/models/enumeration-field.ts

Walkthrough

The checkKey validator in EnumerationField now returns null for empty ('', undefined, null) control values before consulting _choices; it returns { wrongValue: true } if _choices is missing/empty or if no choice key matches a non-empty value.

Changes

Enumeration Field Validator Logic

Layer / File(s) Summary
checkKey Validator Method
projects/netgrif-components-core/src/lib/data-fields/enumeration-field/models/enumeration-field.ts
checkKey short-circuits and returns null for empty or undefined control values before checking _choices. If _choices is missing or empty it returns { wrongValue: true }. For non-empty values it returns { wrongValue: true } when no choice.key === control.value match exists; otherwise returns null.

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: fixing enumeration field validation when no choices are provided, directly matching the PR's primary objective and the bug fix it addresses.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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
Copy Markdown

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@projects/netgrif-components-core/src/lib/data-fields/enumeration-field/models/enumeration-field.ts`:
- Line 84: There is a missing semicolon after the "return null" statement in the
EnumerationField source; open the EnumerationField class in
enumeration-field.ts, locate the method that returns null (the return null
statement shown at line 84) and add a trailing semicolon so the statement
becomes "return null;". Ensure the change is limited to that return statement to
satisfy TS/JS syntax.
- Around line 83-89: The validator treats null inconsistently: update the
initial empty-value check to include null (change the condition controlling the
early-return to: control.value === '' || control.value === undefined ||
control.value === null) so null is considered valid like '' and undefined, and
remove the short-circuit `|| control.value === null` from the find predicate
(leave the find as choice => choice.key === control.value) so matching relies
only on actual choice keys; keep existing behavior for the no-choices branch
using this._choices to return {wrongValue: true} when a non-empty/non-null value
is present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 857f86f7-a2a4-474c-babe-6b9f8c2e5261

📥 Commits

Reviewing files that changed from the base of the PR and between 8c5cf10 and 75e1f76.

📒 Files selected for processing (1)
  • projects/netgrif-components-core/src/lib/data-fields/enumeration-field/models/enumeration-field.ts

Retoocs
Retoocs previously approved these changes May 11, 2026
… validation

Ensure that null values are correctly handled in the validation logic of enumeration fields. This prevents unnecessary errors when null is passed as a control value.
coderabbitai[bot]
coderabbitai Bot previously approved these changes May 11, 2026
Retoocs
Retoocs previously approved these changes May 11, 2026
Replaced `find` with `some` to improve code clarity and intent. The updated method now directly checks for the existence of a matching key, simplifying the logic while maintaining functionality.
@renczesstefan renczesstefan dismissed stale reviews from Retoocs and coderabbitai[bot] via 969a6cd May 11, 2026 14:46
@sonarqubecloud
Copy link
Copy Markdown

@machacjozef machacjozef merged commit 2a1d491 into release/7.0.0-rev10 May 11, 2026
10 of 11 checks passed
@machacjozef machacjozef deleted the NAE-2435 branch May 11, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants