File tree Expand file tree Collapse file tree 3 files changed +24
-5
lines changed Expand file tree Collapse file tree 3 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -475,7 +475,7 @@ export interface IAdvancedFilterCondition {
475
475
476
476
export interface IAdvancedFilter extends IFilter {
477
477
logicalOperator : AdvancedFilterLogicalOperators ;
478
- conditions : IAdvancedFilterCondition [ ] ;
478
+ conditions ? : IAdvancedFilterCondition [ ] ;
479
479
}
480
480
481
481
export enum FilterType {
@@ -846,9 +846,6 @@ export class AdvancedFilter extends Filter {
846
846
extractedConditions = ( conditions as IAdvancedFilterCondition [ ] ) ;
847
847
}
848
848
849
- if ( extractedConditions . length === 0 ) {
850
- throw new Error ( `conditions must be a non-empty array. You passed: ${ conditions } ` ) ;
851
- }
852
849
if ( extractedConditions . length > 2 ) {
853
850
throw new Error ( `AdvancedFilters may not have more than two conditions. You passed: ${ conditions . length } ` ) ;
854
851
}
Original file line number Diff line number Diff line change @@ -246,7 +246,7 @@ export class AdvancedFilterValidator extends FilterValidatorBase {
246
246
} ,
247
247
{
248
248
field : "conditions" ,
249
- validators : [ Validators . fieldRequiredValidator , Validators . filterConditionsValidator ]
249
+ validators : [ Validators . filterConditionsValidator ]
250
250
} ,
251
251
{
252
252
field : "filterType" ,
Original file line number Diff line number Diff line change @@ -3159,6 +3159,28 @@ describe("Unit | Filters", () => {
3159
3159
expect ( filter . toJSON ( ) ) . toEqual ( expectedFilter ) ;
3160
3160
} ) ;
3161
3161
3162
+ it ( "should output the correct json when toJSON is called for empty advanced filter" , ( ) => {
3163
+ // Arrange
3164
+ const expectedFilter : models . IAdvancedFilter = {
3165
+ $schema : "http://powerbi.com/product/schema#advanced" ,
3166
+ target : {
3167
+ table : "a" ,
3168
+ column : "b"
3169
+ } ,
3170
+ conditions : [ ] ,
3171
+ logicalOperator : "And" ,
3172
+ filterType : models . FilterType . Advanced
3173
+ } ;
3174
+
3175
+ // Act
3176
+ const filter = new models . AdvancedFilter (
3177
+ expectedFilter . target as models . IFilterTarget ,
3178
+ expectedFilter . logicalOperator ) ;
3179
+
3180
+ // Assert
3181
+ expect ( filter . toJSON ( ) ) . toEqual ( expectedFilter ) ;
3182
+ } ) ;
3183
+
3162
3184
it ( "can be constructed using either array form or individual arguments" , ( ) => {
3163
3185
// Arrange
3164
3186
const expectedFilter : models . IAdvancedFilter = {
You can’t perform that action at this time.
0 commit comments