diff --git a/src/validation/validators/oneOf.js b/src/validation/validators/oneOf.js index 4476387..5368ede 100644 --- a/src/validation/validators/oneOf.js +++ b/src/validation/validators/oneOf.js @@ -1,5 +1,6 @@ import convert from '../../converters/convert'; import createInfoObject from '../helpers/createInfoObject'; +import getInfoObject from '../helpers/getInfoObject'; import isValid from '../helpers/isValid'; /** @@ -36,7 +37,7 @@ export default function oneOf(...validators) { if (result === true) { return true; } - invalid.push(validator(null, true).type || 'Unknown type'); + invalid.push(getInfoObject(validator).type || 'Unknown type'); } /* eslint-disable prefer-template */ diff --git a/test/validation/validators/oneOf.js b/test/validation/validators/oneOf.js index 6bb9bea..9db3905 100644 --- a/test/validation/validators/oneOf.js +++ b/test/validation/validators/oneOf.js @@ -29,8 +29,8 @@ describe('validators', () => { }); it('should return error if value is invalid', () => { - expect(oneOf(isInteger, isBoolean)('true')) - .toEqual('Was not any of the possible types:\n\nInteger\nBoolean'); + expect(oneOf(/a/, isInteger, isBoolean)('true')) + .toEqual('Was not any of the possible types:\n\n/a/\nInteger\nBoolean'); }); it('should validate correctly', () => {