Skip to content

[O2B-1602] Shared BeamTypesDto should return split input rather than simply validation - #2202

Open
graduta wants to merge 8 commits into
mainfrom
feature/O2B-1602-add-pdp-beam-type-filter
Open

[O2B-1602] Shared BeamTypesDto should return split input rather than simply validation#2202
graduta wants to merge 8 commits into
mainfrom
feature/O2B-1602-add-pdp-beam-type-filter

Conversation

@graduta

@graduta graduta commented Jul 31, 2026

Copy link
Copy Markdown
Member

I have a JIRA ticket

  • branch and/or PR name(s) include(s) JIRA ID
  • issue has "Fix version" assigned
  • issue "Status" is set to "In review"
  • PR labels are selected

Notable changes for users:

  • N/A

Notable changes for developers:

  • BeamTypesFilterDto will now as per the convention return an array of beam types rather than a string which then every usecase (GetAllLhcFills and GetAllRuns) have to split the input
  • tests adapted accordingly

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.17%. Comparing base (bb254ed) to head (11a0a33).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2202      +/-   ##
==========================================
- Coverage   46.20%   46.17%   -0.03%     
==========================================
  Files        1039     1038       -1     
  Lines       17131    17120      -11     
  Branches     3123     3121       -2     
==========================================
- Hits         7915     7905      -10     
+ Misses       9216     9215       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@graduta graduta changed the title [O2B-1602] Add option to filter by pdp beam type [O2B-1602] Shared BeamTypesDto should return split input rather than simply validation Jul 31, 2026
@graduta
graduta marked this pull request as ready for review July 31, 2026 11:39
@graduta
graduta requested a review from isaachilly as a code owner July 31, 2026 11:39

const Joi = require('joi');
const { validateBeamTypes, BEAM_TYPE_INVALID } = require('../../../utilities/beamTypeUtils');
const { CustomJoi } = require('../CustomJoi.js');

@isaachilly isaachilly Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I understand this was not introduced in this PR, so not to be implemented here, but would you agree that CustomJoi is a rather nondescript name and should be changed to something like `StringArrayJoi? If so, I will make a note and then the change.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I do not believe it should be changed to "StringArrayJoi" because the name CustomJoi refers to the wrapper defined in that file.
If you look at the implementation of the wrapper, you will see it defines the method stringArray which is being called in this file.
Thus, to me:

  • "CustomJoi" - informs the developer that it is a custom wrapper around the Joi library
  • "CustomJoi.stringArray()" - it is the call that returns the string array

exports.BeamTypesDto = CustomJoi.stringArray()
.items(Joi.string()
.trim()
.min(2)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this minimum check necessary as the pattern enforces >2 chars with char dash char?

@graduta graduta Aug 1, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

While the pattern will enforce that, I think it is also important to be self-explanatory when writing code, so that it is easy to maintain it.
Moreover, regexes are in general slow, so in this case a length-based match may be faster for scenarios in which we receive thousands of requests within a second.

.min(2)
.max(15)
.pattern(/^[A-Za-z0-9]+ ?- ?[A-Za-z0-9]+$/)
.messages({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The custom validator was the only thing raising BEAM_TYPE_INVALID error so I believe this is now dead message handler code.

Supported by the fact the test/api/runs.test.js LN196 test has been changed to assert the default JOI message format.

Do you agree?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You are correct. I have modified the DTO to have more specific error messages now

@graduta
graduta requested a review from isaachilly August 1, 2026 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants