diff --git a/lib/vocabularies/applicator/dependencies.ts b/lib/vocabularies/applicator/dependencies.ts index f67611286..659db68e1 100644 --- a/lib/vocabularies/applicator/dependencies.ts +++ b/lib/vocabularies/applicator/dependencies.ts @@ -30,7 +30,11 @@ export type DependenciesError = ErrorObject< export const error: KeywordErrorDefinition = { message: ({params: {property, depsCount, deps}}) => { const property_ies = depsCount === 1 ? "property" : "properties" - return str`must have ${property_ies} ${deps} when property ${property} is present` + const quotedDeps = (deps as string) + .split(", ") + .map((v) => `'${v}'`) + .join(", ") + return str`must have ${property_ies} ${quotedDeps} when property '${property}' is present` }, params: ({params: {property, depsCount, deps, missingProperty}}) => _`{property: ${property}, diff --git a/spec/errors.spec.ts b/spec/errors.spec.ts index 5f075845e..a23c2c86c 100644 --- a/spec/errors.spec.ts +++ b/spec/errors.spec.ts @@ -393,7 +393,7 @@ describe("Validation errors", () => { invalidData1 = {a: 0, foo: 1, baz: 3}, invalidData2 = {a: 0, bar: 2} - const msg = "must have properties foo, bar, baz when property a is present" + const msg = "must have properties 'foo', 'bar', 'baz' when property 'a' is present" const validate = ajv.compile(schema) shouldBeValid(validate, data)