@beabee/beabee-common 1.10.7 → 1.10.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/utils/rules.js
CHANGED
|
@@ -43,6 +43,10 @@ function validateRule(filters, rule) {
|
|
|
43
43
|
rule.value.some((v) => !(0, date_1.isValidDate)(v))) {
|
|
44
44
|
throw new error_1.InvalidRule(rule, `Invalid operator argument: date type needs valid absolute or relative date, ${rule.value} given`);
|
|
45
45
|
}
|
|
46
|
+
if ((filter.type === "enum" || filter.type === "array") &&
|
|
47
|
+
rule.value.some((v) => filter.options?.indexOf(v) === -1)) {
|
|
48
|
+
throw new error_1.InvalidRule(rule, `Invalid operator argument: ${filter.type} type expected ${filter.options}, ${rule.value} given`);
|
|
49
|
+
}
|
|
46
50
|
return {
|
|
47
51
|
field: fieldName,
|
|
48
52
|
param: fieldParam,
|
package/dist/esm/utils/rules.js
CHANGED
|
@@ -39,6 +39,10 @@ export function validateRule(filters, rule) {
|
|
|
39
39
|
rule.value.some((v) => !isValidDate(v))) {
|
|
40
40
|
throw new InvalidRule(rule, `Invalid operator argument: date type needs valid absolute or relative date, ${rule.value} given`);
|
|
41
41
|
}
|
|
42
|
+
if ((filter.type === "enum" || filter.type === "array") &&
|
|
43
|
+
rule.value.some((v) => filter.options?.indexOf(v) === -1)) {
|
|
44
|
+
throw new InvalidRule(rule, `Invalid operator argument: ${filter.type} type expected ${filter.options}, ${rule.value} given`);
|
|
45
|
+
}
|
|
42
46
|
return {
|
|
43
47
|
field: fieldName,
|
|
44
48
|
param: fieldParam,
|
|
@@ -31,14 +31,18 @@ interface BaseFilterArgs {
|
|
|
31
31
|
type: FilterType;
|
|
32
32
|
nullable?: boolean;
|
|
33
33
|
}
|
|
34
|
-
export interface
|
|
34
|
+
export interface ArrayFilterArgs<T extends readonly string[] | undefined> extends BaseFilterArgs {
|
|
35
|
+
type: "array";
|
|
36
|
+
options?: T;
|
|
37
|
+
}
|
|
38
|
+
export interface EnumFilterArgs<T extends readonly string[]> extends BaseFilterArgs {
|
|
35
39
|
type: "enum";
|
|
36
40
|
options: T;
|
|
37
41
|
}
|
|
38
42
|
export interface OtherFilterArgs extends BaseFilterArgs {
|
|
39
|
-
type: Exclude<FilterType, "enum">;
|
|
43
|
+
type: Exclude<FilterType, "array" | "enum">;
|
|
40
44
|
}
|
|
41
|
-
export type FilterArgs = EnumFilterArgs | OtherFilterArgs;
|
|
45
|
+
export type FilterArgs = ArrayFilterArgs<readonly string[] | undefined> | EnumFilterArgs<readonly string[]> | OtherFilterArgs;
|
|
42
46
|
export type Filters<T extends string = string> = Record<T, FilterArgs>;
|
|
43
47
|
export interface RuleOperatorParams {
|
|
44
48
|
args: number;
|