@fogpipe/forma-core 0.6.0 → 0.8.0
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/{chunk-IRLYWN3R.js → chunk-VHKUCCAC.js} +13 -1
- package/dist/{chunk-IRLYWN3R.js.map → chunk-VHKUCCAC.js.map} +1 -1
- package/dist/engine/calculate.d.ts +64 -0
- package/dist/engine/calculate.d.ts.map +1 -0
- package/dist/engine/enabled.d.ts +40 -0
- package/dist/engine/enabled.d.ts.map +1 -0
- package/dist/engine/index.cjs +12 -0
- package/dist/engine/index.cjs.map +1 -1
- package/dist/engine/index.d.ts +12 -255
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/index.js +1 -1
- package/dist/engine/required.d.ts +45 -0
- package/dist/engine/required.d.ts.map +1 -0
- package/dist/engine/validate.d.ts +59 -0
- package/dist/engine/validate.d.ts.map +1 -0
- package/dist/engine/visibility.d.ts +52 -0
- package/dist/engine/visibility.d.ts.map +1 -0
- package/dist/feel/index.d.ts +12 -15
- package/dist/feel/index.d.ts.map +1 -0
- package/dist/index.cjs +12 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/dist/{types-Bs3CG9JZ.d.cts → types.d.ts} +31 -30
- package/dist/types.d.ts.map +1 -0
- package/package.json +3 -2
- package/src/__tests__/validate.test.ts +278 -0
- package/src/engine/validate.ts +14 -0
- package/src/index.ts +36 -2
- package/src/types.ts +2 -0
- package/dist/engine/index.d.cts +0 -258
- package/dist/feel/index.d.cts +0 -105
- package/dist/index.d.cts +0 -3
- package/dist/types-Bs3CG9JZ.d.ts +0 -283
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Required Fields Engine
|
|
3
|
+
*
|
|
4
|
+
* Determines which fields are currently required based on
|
|
5
|
+
* conditional requiredWhen expressions and schema required array.
|
|
6
|
+
*/
|
|
7
|
+
import type { Forma, FieldDefinition, EvaluationContext, RequiredFieldsResult } from "../types.js";
|
|
8
|
+
export interface RequiredOptions {
|
|
9
|
+
/** Pre-calculated computed values */
|
|
10
|
+
computed?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Determine which fields are currently required
|
|
14
|
+
*
|
|
15
|
+
* Returns a map of field paths to boolean required states.
|
|
16
|
+
* Evaluates requiredWhen expressions for conditional requirements.
|
|
17
|
+
*
|
|
18
|
+
* @param data - Current form data
|
|
19
|
+
* @param spec - Form specification
|
|
20
|
+
* @param options - Optional pre-calculated computed values
|
|
21
|
+
* @returns Map of field paths to required states
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const required = getRequired(
|
|
25
|
+
* { hasInsurance: true },
|
|
26
|
+
* forma
|
|
27
|
+
* );
|
|
28
|
+
* // => { hasInsurance: true, insuranceProvider: true, policyNumber: true }
|
|
29
|
+
*/
|
|
30
|
+
export declare function getRequired(data: Record<string, unknown>, spec: Forma, options?: RequiredOptions): RequiredFieldsResult;
|
|
31
|
+
/**
|
|
32
|
+
* Check if a single field is required based on requiredWhen or schema
|
|
33
|
+
* @internal Exported for use by validate.ts
|
|
34
|
+
*/
|
|
35
|
+
export declare function isFieldRequired(fieldPath: string, fieldDef: FieldDefinition, spec: Forma, context: EvaluationContext): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Check if a single field is currently required
|
|
38
|
+
*
|
|
39
|
+
* @param fieldPath - Path to the field
|
|
40
|
+
* @param data - Current form data
|
|
41
|
+
* @param spec - Form specification
|
|
42
|
+
* @returns True if the field is required
|
|
43
|
+
*/
|
|
44
|
+
export declare function isRequired(fieldPath: string, data: Record<string, unknown>, spec: Forma): boolean;
|
|
45
|
+
//# sourceMappingURL=required.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"required.d.ts","sourceRoot":"","sources":["../../src/engine/required.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,KAAK,EACL,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAOrB,MAAM,WAAW,eAAe;IAC9B,qCAAqC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAMD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,IAAI,EAAE,KAAK,EACX,OAAO,GAAE,eAAoB,GAC5B,oBAAoB,CAgDtB;AAMD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAQT;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,IAAI,EAAE,KAAK,GACV,OAAO,CAcT"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation Engine
|
|
3
|
+
*
|
|
4
|
+
* Validates form data against Forma rules including:
|
|
5
|
+
* - JSON Schema type validation
|
|
6
|
+
* - Required field validation (with conditional requiredWhen)
|
|
7
|
+
* - Custom FEEL validation rules
|
|
8
|
+
* - Array item validation
|
|
9
|
+
*/
|
|
10
|
+
import type { Forma, ValidationResult, FieldError } from "../types.js";
|
|
11
|
+
export interface ValidateOptions {
|
|
12
|
+
/** Pre-calculated computed values */
|
|
13
|
+
computed?: Record<string, unknown>;
|
|
14
|
+
/** Pre-calculated visibility */
|
|
15
|
+
visibility?: Record<string, boolean>;
|
|
16
|
+
/** Only validate visible fields (default: true) */
|
|
17
|
+
onlyVisible?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Validate form data against a Forma
|
|
21
|
+
*
|
|
22
|
+
* Performs comprehensive validation including:
|
|
23
|
+
* - Required field checks (respecting conditional requiredWhen)
|
|
24
|
+
* - JSON Schema type validation
|
|
25
|
+
* - Custom FEEL validation rules
|
|
26
|
+
* - Array min/max items validation
|
|
27
|
+
* - Array item field validation
|
|
28
|
+
*
|
|
29
|
+
* By default, only visible fields are validated.
|
|
30
|
+
*
|
|
31
|
+
* @param data - Current form data
|
|
32
|
+
* @param spec - Form specification
|
|
33
|
+
* @param options - Validation options
|
|
34
|
+
* @returns Validation result with valid flag and errors array
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* const result = validate(
|
|
38
|
+
* { name: "", age: 15 },
|
|
39
|
+
* forma
|
|
40
|
+
* );
|
|
41
|
+
* // => {
|
|
42
|
+
* // valid: false,
|
|
43
|
+
* // errors: [
|
|
44
|
+
* // { field: "name", message: "Name is required", severity: "error" },
|
|
45
|
+
* // { field: "age", message: "Must be 18 or older", severity: "error" }
|
|
46
|
+
* // ]
|
|
47
|
+
* // }
|
|
48
|
+
*/
|
|
49
|
+
export declare function validate(data: Record<string, unknown>, spec: Forma, options?: ValidateOptions): ValidationResult;
|
|
50
|
+
/**
|
|
51
|
+
* Validate a single field
|
|
52
|
+
*
|
|
53
|
+
* @param fieldPath - Path to the field
|
|
54
|
+
* @param data - Current form data
|
|
55
|
+
* @param spec - Form specification
|
|
56
|
+
* @returns Array of errors for this field
|
|
57
|
+
*/
|
|
58
|
+
export declare function validateSingleField(fieldPath: string, data: Record<string, unknown>, spec: Forma): FieldError[];
|
|
59
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/engine/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EACV,KAAK,EAIL,gBAAgB,EAChB,UAAU,EAEX,MAAM,aAAa,CAAC;AASrB,MAAM,WAAW,eAAe;IAC9B,qCAAqC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,gCAAgC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,mDAAmD;IACnD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,IAAI,EAAE,KAAK,EACX,OAAO,GAAE,eAAoB,GAC5B,gBAAgB,CA6ClB;AA2fD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,IAAI,EAAE,KAAK,GACV,UAAU,EAAE,CAqBd"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visibility Engine
|
|
3
|
+
*
|
|
4
|
+
* Determines which fields should be visible based on form data
|
|
5
|
+
* and Forma visibility rules.
|
|
6
|
+
*/
|
|
7
|
+
import type { Forma, VisibilityResult } from "../types.js";
|
|
8
|
+
export interface VisibilityOptions {
|
|
9
|
+
/** Pre-calculated computed values (avoids recalculation) */
|
|
10
|
+
computed?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Determine visibility for all fields in a form
|
|
14
|
+
*
|
|
15
|
+
* Returns a map of field paths to boolean visibility states.
|
|
16
|
+
* Fields without visibleWhen expressions are always visible.
|
|
17
|
+
*
|
|
18
|
+
* @param data - Current form data
|
|
19
|
+
* @param spec - Form specification
|
|
20
|
+
* @param options - Optional pre-calculated computed values
|
|
21
|
+
* @returns Map of field paths to visibility states
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const visibility = getVisibility(
|
|
25
|
+
* { age: 21, hasLicense: true },
|
|
26
|
+
* forma
|
|
27
|
+
* );
|
|
28
|
+
* // => { age: true, hasLicense: true, vehicleType: true, ... }
|
|
29
|
+
*/
|
|
30
|
+
export declare function getVisibility(data: Record<string, unknown>, spec: Forma, options?: VisibilityOptions): VisibilityResult;
|
|
31
|
+
/**
|
|
32
|
+
* Check if a single field is visible
|
|
33
|
+
*
|
|
34
|
+
* Useful for checking visibility of one field without computing all.
|
|
35
|
+
*
|
|
36
|
+
* @param fieldPath - Field path to check
|
|
37
|
+
* @param data - Current form data
|
|
38
|
+
* @param spec - Form specification
|
|
39
|
+
* @param options - Optional pre-calculated computed values
|
|
40
|
+
* @returns True if the field is visible
|
|
41
|
+
*/
|
|
42
|
+
export declare function isFieldVisible(fieldPath: string, data: Record<string, unknown>, spec: Forma, options?: VisibilityOptions): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Determine which pages are visible in a wizard form
|
|
45
|
+
*
|
|
46
|
+
* @param data - Current form data
|
|
47
|
+
* @param spec - Form specification with pages
|
|
48
|
+
* @param options - Optional pre-calculated computed values
|
|
49
|
+
* @returns Map of page IDs to visibility states
|
|
50
|
+
*/
|
|
51
|
+
export declare function getPageVisibility(data: Record<string, unknown>, spec: Forma, options?: VisibilityOptions): Record<string, boolean>;
|
|
52
|
+
//# sourceMappingURL=visibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visibility.d.ts","sourceRoot":"","sources":["../../src/engine/visibility.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,KAAK,EAGL,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAOrB,MAAM,WAAW,iBAAiB;IAChC,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAMD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,IAAI,EAAE,KAAK,EACX,OAAO,GAAE,iBAAsB,GAC9B,gBAAgB,CAsBlB;AA+ED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,IAAI,EAAE,KAAK,EACX,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAkBT;AAMD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,IAAI,EAAE,KAAK,EACX,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAuBzB"}
|
package/dist/feel/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { F as FEELExpression, E as EvaluationContext } from '../types-Bs3CG9JZ.js';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* FEEL Expression Evaluator
|
|
5
3
|
*
|
|
@@ -14,17 +12,17 @@ import { F as FEELExpression, E as EvaluationContext } from '../types-Bs3CG9JZ.j
|
|
|
14
12
|
* - `itemIndex` - Current array item index (0-based)
|
|
15
13
|
* - `value` - Current field value (in validation expressions)
|
|
16
14
|
*/
|
|
17
|
-
|
|
18
|
-
interface EvaluateResult<T = unknown> {
|
|
15
|
+
import type { EvaluationContext, FEELExpression } from "../types.js";
|
|
16
|
+
export interface EvaluateResult<T = unknown> {
|
|
19
17
|
success: true;
|
|
20
18
|
value: T;
|
|
21
19
|
}
|
|
22
|
-
interface EvaluateError {
|
|
20
|
+
export interface EvaluateError {
|
|
23
21
|
success: false;
|
|
24
22
|
error: string;
|
|
25
23
|
expression: string;
|
|
26
24
|
}
|
|
27
|
-
type EvaluationOutcome<T = unknown> = EvaluateResult<T> | EvaluateError;
|
|
25
|
+
export type EvaluationOutcome<T = unknown> = EvaluateResult<T> | EvaluateError;
|
|
28
26
|
/**
|
|
29
27
|
* Evaluate a FEEL expression and return the result
|
|
30
28
|
*
|
|
@@ -47,7 +45,7 @@ type EvaluationOutcome<T = unknown> = EvaluateResult<T> | EvaluateError;
|
|
|
47
45
|
* evaluate("item.frequency = \"daily\"", { data: {}, item: { frequency: "daily" } })
|
|
48
46
|
* // => { success: true, value: true }
|
|
49
47
|
*/
|
|
50
|
-
declare function evaluate<T = unknown>(expression: FEELExpression, context: EvaluationContext): EvaluationOutcome<T>;
|
|
48
|
+
export declare function evaluate<T = unknown>(expression: FEELExpression, context: EvaluationContext): EvaluationOutcome<T>;
|
|
51
49
|
/**
|
|
52
50
|
* Evaluate a FEEL expression expecting a boolean result
|
|
53
51
|
*
|
|
@@ -58,7 +56,7 @@ declare function evaluate<T = unknown>(expression: FEELExpression, context: Eval
|
|
|
58
56
|
* @param context - Evaluation context
|
|
59
57
|
* @returns Boolean result (false on error)
|
|
60
58
|
*/
|
|
61
|
-
declare function evaluateBoolean(expression: FEELExpression, context: EvaluationContext): boolean;
|
|
59
|
+
export declare function evaluateBoolean(expression: FEELExpression, context: EvaluationContext): boolean;
|
|
62
60
|
/**
|
|
63
61
|
* Evaluate a FEEL expression expecting a numeric result
|
|
64
62
|
*
|
|
@@ -68,7 +66,7 @@ declare function evaluateBoolean(expression: FEELExpression, context: Evaluation
|
|
|
68
66
|
* @param context - Evaluation context
|
|
69
67
|
* @returns Numeric result or null on error
|
|
70
68
|
*/
|
|
71
|
-
declare function evaluateNumber(expression: FEELExpression, context: EvaluationContext): number | null;
|
|
69
|
+
export declare function evaluateNumber(expression: FEELExpression, context: EvaluationContext): number | null;
|
|
72
70
|
/**
|
|
73
71
|
* Evaluate a FEEL expression expecting a string result
|
|
74
72
|
*
|
|
@@ -76,7 +74,7 @@ declare function evaluateNumber(expression: FEELExpression, context: EvaluationC
|
|
|
76
74
|
* @param context - Evaluation context
|
|
77
75
|
* @returns String result or null on error
|
|
78
76
|
*/
|
|
79
|
-
declare function evaluateString(expression: FEELExpression, context: EvaluationContext): string | null;
|
|
77
|
+
export declare function evaluateString(expression: FEELExpression, context: EvaluationContext): string | null;
|
|
80
78
|
/**
|
|
81
79
|
* Evaluate multiple FEEL expressions at once
|
|
82
80
|
*
|
|
@@ -86,20 +84,19 @@ declare function evaluateString(expression: FEELExpression, context: EvaluationC
|
|
|
86
84
|
* @param context - Evaluation context
|
|
87
85
|
* @returns Map of field names to boolean results
|
|
88
86
|
*/
|
|
89
|
-
declare function evaluateBooleanBatch(expressions: Record<string, FEELExpression>, context: EvaluationContext): Record<string, boolean>;
|
|
87
|
+
export declare function evaluateBooleanBatch(expressions: Record<string, FEELExpression>, context: EvaluationContext): Record<string, boolean>;
|
|
90
88
|
/**
|
|
91
89
|
* Check if a FEEL expression is syntactically valid
|
|
92
90
|
*
|
|
93
91
|
* @param expression - FEEL expression to validate
|
|
94
92
|
* @returns True if the expression can be parsed
|
|
95
93
|
*/
|
|
96
|
-
declare function isValidExpression(expression: FEELExpression): boolean;
|
|
94
|
+
export declare function isValidExpression(expression: FEELExpression): boolean;
|
|
97
95
|
/**
|
|
98
96
|
* Validate a FEEL expression and return any parsing errors
|
|
99
97
|
*
|
|
100
98
|
* @param expression - FEEL expression to validate
|
|
101
99
|
* @returns Null if valid, error message if invalid
|
|
102
100
|
*/
|
|
103
|
-
declare function validateExpression(expression: FEELExpression): string | null;
|
|
104
|
-
|
|
105
|
-
export { type EvaluateError, type EvaluateResult, type EvaluationOutcome, evaluate, evaluateBoolean, evaluateBooleanBatch, evaluateNumber, evaluateString, isValidExpression, validateExpression };
|
|
101
|
+
export declare function validateExpression(expression: FEELExpression): string | null;
|
|
102
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/feel/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAMrE,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,OAAO;IACzC,OAAO,EAAE,IAAI,CAAC;IACd,KAAK,EAAE,CAAC,CAAC;CACV;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,iBAAiB,CAAC,CAAC,GAAG,OAAO,IAAI,cAAc,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC;AAuD/E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,GAAG,OAAO,EAClC,UAAU,EAAE,cAAc,EAC1B,OAAO,EAAE,iBAAiB,GACzB,iBAAiB,CAAC,CAAC,CAAC,CAetB;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,cAAc,EAC1B,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAwBT;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,cAAc,EAC1B,OAAO,EAAE,iBAAiB,GACzB,MAAM,GAAG,IAAI,CAkBf;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,cAAc,EAC1B,OAAO,EAAE,iBAAiB,GACzB,MAAM,GAAG,IAAI,CAkBf;AAMD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EAC3C,OAAO,EAAE,iBAAiB,GACzB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzB;AAMD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO,CASrE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAc5E"}
|
package/dist/index.cjs
CHANGED
|
@@ -730,6 +730,18 @@ function validateType(path, value, schema, fieldDef) {
|
|
|
730
730
|
};
|
|
731
731
|
}
|
|
732
732
|
}
|
|
733
|
+
if ("multipleOf" in schema && schema.multipleOf !== void 0) {
|
|
734
|
+
const multipleOf = schema.multipleOf;
|
|
735
|
+
const remainder = Math.abs(value % multipleOf);
|
|
736
|
+
const isValid = remainder < 1e-10 || Math.abs(remainder - multipleOf) < 1e-10;
|
|
737
|
+
if (!isValid) {
|
|
738
|
+
return {
|
|
739
|
+
field: path,
|
|
740
|
+
message: `${label} must be a multiple of ${multipleOf}`,
|
|
741
|
+
severity: "error"
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
}
|
|
733
745
|
return null;
|
|
734
746
|
}
|
|
735
747
|
case "boolean": {
|