Skip to content

Commit

Permalink
fix(atomic,headless): add maximum value of 10 for 'desiredCount' (#3089)
Browse files Browse the repository at this point in the history
  • Loading branch information
aprudhomme-coveo authored Aug 10, 2023
1 parent 6fc30f4 commit 35bb410
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {BooleanValue, NumberValue, Schema} from '@coveo/bueno';
import {BooleanValue, Schema} from '@coveo/bueno';
import {
AutomaticFacetGenerator,
AutomaticFacetGeneratorState,
Expand Down Expand Up @@ -74,10 +74,8 @@ export class AtomicAutomaticFacetGenerator implements InitializableComponent {

private validateProps() {
new Schema({
desiredCount: new NumberValue({min: 1, required: true}),
areCollapsed: new BooleanValue({default: true, required: false}),
}).validate({
desiredCount: this.desiredCount,
areCollapsed: this.areCollapsed,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import {
import {facetValueDefinition} from '../facet-set/facet-set-validate-payload';
import {FacetValue} from '../facet-set/interfaces/response';
import {facetIdDefinition} from '../generic/facet-actions-validation';
import {
DESIRED_COUNT_MAXIMUM,
DESIRED_COUNT_MINIMUM,
} from './automatic-facet-set-constants';

export interface ToggleSelectAutomaticFacetValueActionCreatorPayload {
/**
Expand All @@ -20,7 +24,10 @@ export interface ToggleSelectAutomaticFacetValueActionCreatorPayload {
selection: FacetValue;
}

const desiredCountDefinition = new NumberValue({min: 1});
const desiredCountDefinition = new NumberValue({
min: DESIRED_COUNT_MINIMUM,
max: DESIRED_COUNT_MAXIMUM,
});
export const setDesiredCount = createAction(
'automaticFacet/setDesiredCount',
(payload: number) => validatePayload(payload, desiredCountDefinition)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const DESIRED_COUNT_MAXIMUM = 10;
export const DESIRED_COUNT_MINIMUM = 1;

0 comments on commit 35bb410

Please sign in to comment.