From 71d3d89b229cf5adaa3f4cae7762615858403197 Mon Sep 17 00:00:00 2001 From: Paris Holley Date: Fri, 10 Feb 2023 08:14:32 -0700 Subject: [PATCH] make path available to validation rules --- plugins/validation/src/validation.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/validation/src/validation.ts b/plugins/validation/src/validation.ts index 5fac7f73..63bdb231 100644 --- a/plugins/validation/src/validation.ts +++ b/plugins/validation/src/validation.ts @@ -38,7 +38,7 @@ export function validation(): ExtensionFactory { interface ValidationRule { readonly message: string | ((value: StateValueAtPath) => string) - readonly rule: (v: StateValueAtPath) => boolean + readonly rule: (v: StateValueAtPath, p: Path) => boolean readonly severity: ValidationSeverity; } @@ -91,7 +91,7 @@ export function validation(): ExtensionFactory { const [existingRules, nestedRulesKeys] = getRulesAndNested(l.path); for (let i = 0; i < existingRules.length; i += 1) { const r = existingRules[i]; - if (!r.rule(l.value)) { + if (!r.rule(l.value, l.path)) { const err = { path: l.path, message: typeof r.message === 'function' ? r.message(l.value) : r.message,