@wallarm-org/design-system 0.88.1 → 0.88.2
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.
|
@@ -2,4 +2,12 @@ import type { FilterOperator } from '../../types';
|
|
|
2
2
|
import type { ParserState } from './types';
|
|
3
3
|
export declare const validateField: (s: ParserState, name: string) => void;
|
|
4
4
|
export declare const validateOperator: (s: ParserState, op: string, fieldName: string) => FilterOperator;
|
|
5
|
+
/**
|
|
6
|
+
* Validate pasted values through the *same* rules as inline typing
|
|
7
|
+
* (`getInvalidValueIndices`): a custom `validate`, `getSuggestions` fields, and
|
|
8
|
+
* `strictValues: false` all mean "the value list is a hint, not an allowlist",
|
|
9
|
+
* and grouped value options are flattened to their committable leaves. Reusing
|
|
10
|
+
* that one path keeps paste and typing in agreement — a value accepted when
|
|
11
|
+
* typed must not be rejected when pasted (AS-1377).
|
|
12
|
+
*/
|
|
5
13
|
export declare const validateValues: (s: ParserState, fieldName: string, values: Array<string | number>) => void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getInvalidValueIndices } from "../validation.js";
|
|
1
2
|
import { FilterParseError } from "./error.js";
|
|
2
3
|
import { OPERATORS } from "./tokenizer.js";
|
|
3
4
|
const validateField = (s, name)=>{
|
|
@@ -9,17 +10,10 @@ const validateOperator = (s, op, fieldName)=>{
|
|
|
9
10
|
if (field?.operators && !field.operators.includes(op)) throw FilterParseError(`Operator '${op}' is not allowed for field '${fieldName}'`);
|
|
10
11
|
return op;
|
|
11
12
|
};
|
|
12
|
-
const getAllowedValues = (field)=>{
|
|
13
|
-
if (field.values && field.values.length > 0) return new Set(field.values.map((v)=>String(v.value)));
|
|
14
|
-
if (field.options && field.options.length > 0) return new Set(field.options);
|
|
15
|
-
return null;
|
|
16
|
-
};
|
|
17
13
|
const validateValues = (s, fieldName, values)=>{
|
|
18
14
|
const field = s.fields.find((f)=>f.name === fieldName);
|
|
19
15
|
if (!field) return;
|
|
20
|
-
const
|
|
21
|
-
if (!allowed) return;
|
|
22
|
-
const invalid = values.filter((v)=>!allowed.has(String(v)));
|
|
16
|
+
const invalid = getInvalidValueIndices(field, values).map((i)=>values[i]);
|
|
23
17
|
if (invalid.length > 0) {
|
|
24
18
|
const formatted = invalid.map((v)=>`"${v}"`).join(', ');
|
|
25
19
|
throw FilterParseError(`Invalid value ${formatted} for field '${fieldName}'`);
|