@@ -17,6 +17,7 @@ const { RUN_QUALITIES } = require('../../enums/RunQualities.js');
1717const { IntegerComparisonDto, FloatComparisonDto } = require ( './NumericalComparisonDto.js' ) ;
1818const { RUN_CALIBRATION_STATUS } = require ( '../../enums/RunCalibrationStatus.js' ) ;
1919const { RUN_DEFINITIONS } = require ( '../../enums/RunDefinition.js' ) ;
20+ const { singleRunsCollectionCustomCheck } = require ( '../utils.js' ) ;
2021
2122const DetectorsFilterDto = Joi . object ( {
2223 operator : Joi . string ( ) . valid ( 'or' , 'and' , 'none' ) . required ( ) ,
@@ -128,12 +129,13 @@ exports.RunFilterDto = Joi.object({
128129 } )
129130 . custom ( ( detectorsQcObj , helpers ) => {
130131 const [ { dataPassIds, simulationPassIds, lhcPeriodIds } ] = helpers . state . ancestors ;
131- const runsCollectionFilters = [ dataPassIds , simulationPassIds , lhcPeriodIds ] . filter ( ( { length } = { } ) => length >= 1 ) ;
132132
133- if ( runsCollectionFilters . length !== 1 || runsCollectionFilters [ 0 ] . length !== 1 ) {
134- return helpers . message ( 'Filtering by detector not-bad fraction is allowed only with exactly one of: ' +
135- 'dataPassIds, simulationPassIds, lhcPeriodIds with exactly one ID.' ) ;
136- }
133+ singleRunsCollectionCustomCheck (
134+ { dataPassIds, simulationPassIds, lhcPeriodIds } ,
135+ helpers ,
136+ 'Filtering by detector not-bad fraction is allowed only when ' +
137+ 'the dataPassIds, simulationPassIds and lhcPeriodIds filters collectively contain exactly one ID' ,
138+ ) ;
137139
138140 return detectorsQcObj ;
139141 } ) ,
0 commit comments