Skip to content

fix(condo): DOMA-13432 added commission validation#7823

Open
vovaaxeapolla wants to merge 2 commits into
mainfrom
fix/condo/DOMA-13432/added-commission-validation
Open

fix(condo): DOMA-13432 added commission validation#7823
vovaaxeapolla wants to merge 2 commits into
mainfrom
fix/condo/DOMA-13432/added-commission-validation

Conversation

@vovaaxeapolla

@vovaaxeapolla vovaaxeapolla commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes

    • Tightened fee distribution JSON validation so percent, minAmount, and maxAmount only accept properly formatted numeric strings.
    • Ensures invalid shapes (wrong types, missing required fields, and unexpected properties) are rejected.
  • Tests

    • Added a Jest test suite covering multiple valid payload shapes and extensive invalid scenarios, including format rules for percent, minAmount, and maxAmount.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 73fd91cd-9524-43bb-8c49-63867797be51

📥 Commits

Reviewing files that changed from the base of the PR and between 338fde2 and 4e6b3e5.

📒 Files selected for processing (2)
  • apps/condo/domains/acquiring/schema/fields/json/FeeDistribution.js
  • apps/condo/domains/acquiring/schema/fields/json/FeeDistribution.spec.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/condo/domains/acquiring/schema/fields/json/FeeDistribution.js
  • apps/condo/domains/acquiring/schema/fields/json/FeeDistribution.spec.js

📝 Walkthrough

Walkthrough

FeeDistributionJsonSchema now restricts percent, minAmount, and maxAmount to pattern-matching string values, exports FeeDistributionSchemaJsonValidator, and adds Jest coverage for accepted payload shapes and field-level numeric-string validation.

Changes

Fee distribution schema validation

Layer / File(s) Summary
Schema pattern constraints and validator export
apps/condo/domains/acquiring/schema/fields/json/FeeDistribution.js
percent, minAmount, and maxAmount now require regex-matching string values, and FeeDistributionSchemaJsonValidator is exported.
Validator test suite
apps/condo/domains/acquiring/schema/fields/json/FeeDistribution.spec.js
New Jest cases cover valid and invalid payload shapes, plus parameterized checks for percent, minAmount, and maxAmount format rules.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: dkoviazin, YEgorLu

🚥 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 matches the main change: adding commission fee validation and related tests.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/condo/DOMA-13432/added-commission-validation

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 338fde28d0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

module.exports = {
FEE_DISTRIBUTION_SCHEMA_FIELD,
FEE_DISTRIBUTION_QUERY_LIST,
FeeDistributionSchemaJsonValidator,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep the validator out of the public API

AGENTS.md asks not to export internal constants/utilities solely for tests; this adds the compiled AJV validator to the production module's public API just so FeeDistribution.spec.js can import it. That exposes an implementation detail that other code can start depending on, so please test through FEE_DISTRIBUTION_SCHEMA_FIELD.hooks.validateInput or move validation into a deliberately public helper instead.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 (1)
apps/condo/domains/acquiring/schema/fields/json/FeeDistribution.spec.js (1)

16-16: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use faker.datatype.uuid() instead of a hardcoded UUID.

As per coding guidelines, **/*.{test.js,spec.js,spec.ts} files should "generate UUIDs with faker.datatype.uuid()" rather than hardcoded literals.

♻️ Proposed fix
+const { faker } = require('`@faker-js/faker`')
+
 const { FeeDistributionSchemaJsonValidator } = require('./FeeDistribution')
...
-            category: '123e4567-e89b-12d3-a456-426614174000',
+            category: faker.datatype.uuid(),
...
-                category: '123e4567-e89b-12d3-a456-426614174000',
+                category: faker.datatype.uuid(),

Also applies to: 23-23

🤖 Prompt for 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.

In `@apps/condo/domains/acquiring/schema/fields/json/FeeDistribution.spec.js` at
line 16, The test data in FeeDistribution.spec.js is using hardcoded UUID
literals instead of generated values. Update the affected fixture/object
assignments in this spec to use faker.datatype.uuid() for the category and any
other UUID fields, keeping the existing test setup aligned with the UUID
generation guideline while preserving the same structure around the relevant
test data.

Source: Coding guidelines

🤖 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 `@apps/condo/domains/acquiring/schema/fields/json/FeeDistribution.js`:
- Around line 33-35: The percent validation in FeeDistribution currently only
enforces numeric-string shape in the schema field definition and still allows
arbitrarily large values. Update the validation for the percent property in
FeeDistribution so it also enforces an upper bound such as 100, using a
secondary/custom check or format-based validation since AJV range keywords won’t
apply to a string type. Keep the existing pattern for format, but ensure the
commission validation in the same schema rejects out-of-range values.

---

Nitpick comments:
In `@apps/condo/domains/acquiring/schema/fields/json/FeeDistribution.spec.js`:
- Line 16: The test data in FeeDistribution.spec.js is using hardcoded UUID
literals instead of generated values. Update the affected fixture/object
assignments in this spec to use faker.datatype.uuid() for the category and any
other UUID fields, keeping the existing test setup aligned with the UUID
generation guideline while preserving the same structure around the relevant
test data.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 82c65ce1-e546-48de-8fb6-325f40e8b64a

📥 Commits

Reviewing files that changed from the base of the PR and between 0f782a1 and 338fde2.

📒 Files selected for processing (2)
  • apps/condo/domains/acquiring/schema/fields/json/FeeDistribution.js
  • apps/condo/domains/acquiring/schema/fields/json/FeeDistribution.spec.js

Comment thread apps/condo/domains/acquiring/schema/fields/json/FeeDistribution.js Outdated
@sonarqubecloud

sonarqubecloud Bot commented Jul 7, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant