File tree Expand file tree Collapse file tree 2 files changed +51
-4
lines changed Expand file tree Collapse file tree 2 files changed +51
-4
lines changed Original file line number Diff line number Diff line change 1+ ### Changed
2+
3+ - Support ` min() ` and ` max() ` of numbers in the expression language.
4+ This allows for simpler rules when a field may be a number or array of numbers.
5+
6+ <!--
7+ ### Fixed
8+
9+ - A bullet item for the Fixed category.
10+
11+ -->
12+ <!--
13+ ### Deprecated
14+
15+ - A bullet item for the Deprecated category.
16+
17+ -->
18+ <!--
19+ ### Removed
20+
21+ - A bullet item for the Removed category.
22+
23+ -->
24+ <!--
25+ ### Security
26+
27+ - A bullet item for the Security category.
28+
29+ -->
30+ <!--
31+ ### Infrastructure
32+
33+ - A bullet item for the Infrastructure category.
34+
35+ -->
Original file line number Diff line number Diff line change @@ -79,11 +79,23 @@ export const expressionFunctions = {
7979 }
8080 return typeof operand
8181 } ,
82- min : ( list : number [ ] ) : number | null => {
83- return list != null ? Math . min ( ...list . map ( Number ) . filter ( ( x ) => ! isNaN ( x ) ) ) : null
82+ min : ( list : number | number [ ] ) : number | null => {
83+ if ( list == null ) {
84+ return null
85+ }
86+ if ( ! Array . isArray ( list ) ) {
87+ list = [ list ]
88+ }
89+ return Math . min ( ...list . map ( Number ) . filter ( ( x ) => ! isNaN ( x ) ) )
8490 } ,
85- max : ( list : number [ ] ) : number | null => {
86- return list != null ? Math . max ( ...list . map ( Number ) . filter ( ( x ) => ! isNaN ( x ) ) ) : null
91+ max : ( list : number | number [ ] ) : number | null => {
92+ if ( list == null ) {
93+ return null
94+ }
95+ if ( ! Array . isArray ( list ) ) {
96+ list = [ list ]
97+ }
98+ return Math . max ( ...list . map ( Number ) . filter ( ( x ) => ! isNaN ( x ) ) )
8799 } ,
88100 length : < T > ( list : T [ ] ) : number | null => {
89101 if ( Array . isArray ( list ) || typeof list == 'string' ) {
You can’t perform that action at this time.
0 commit comments