diff --git a/next/src/validation/composition.ts b/next/src/validation/composition.ts index 3030c2e8..e969b0d7 100644 --- a/next/src/validation/composition.ts +++ b/next/src/validation/composition.ts @@ -80,7 +80,7 @@ export function validateAnyOf( { path, validation: 'anyOf', - message: 'Must match at least one of the provided schemas', + message: `The option "${value}" is not valid.`, }, ] } @@ -127,7 +127,7 @@ export function validateOneOf( { path, validation: 'oneOf', - message: 'Must match exactly one of the provided schemas', + message: `The option "${value}" is not valid.`, }, ] } @@ -137,7 +137,7 @@ export function validateOneOf( { path, validation: 'oneOf', - message: 'Must match exactly one schema but matches multiple', + message: `The option "${value}" is not valid.`, }, ] } diff --git a/next/test/validation/composition.test.ts b/next/test/validation/composition.test.ts index e274ab76..39d89f91 100644 --- a/next/test/validation/composition.test.ts +++ b/next/test/validation/composition.test.ts @@ -149,7 +149,7 @@ describe('schema composition validators', () => { const errors = validateSchema(value, schema) expect(errors).toHaveLength(1) expect(errors[0].validation).toBe('anyOf') - expect(errors[0].message).toBe('Must match at least one of the provided schemas') + expect(errors[0].message).toBe(`The option "${value}" is not valid.`) }) }) @@ -256,7 +256,7 @@ describe('schema composition validators', () => { const errors = validateSchema(value, schema) expect(errors).toHaveLength(1) expect(errors[0].validation).toBe('oneOf') - expect(errors[0].message).toBe('Must match exactly one of the provided schemas') + expect(errors[0].message).toBe(`The option "${value}" is not valid.`) }) it('should fail when value matches multiple schemas', () => { @@ -264,7 +264,7 @@ describe('schema composition validators', () => { const errors = validateSchema(value, schema) expect(errors).toHaveLength(1) expect(errors[0].validation).toBe('oneOf') - expect(errors[0].message).toBe('Must match exactly one schema but matches multiple') + expect(errors[0].message).toBe(`The option "${value}" is not valid.`) }) }) @@ -322,7 +322,7 @@ describe('schema composition validators', () => { const errors = validateSchema(value, schema) expect(errors).toHaveLength(1) expect(errors[0].validation).toBe('oneOf') - expect(errors[0].message).toBe('Must match exactly one schema but matches multiple') + expect(errors[0].message).toBe(`The option "${value}" is not valid.`) }) })