diff --git a/validator.js b/validator.js index d30686157..98bf256f0 100644 --- a/validator.js +++ b/validator.js @@ -134,6 +134,14 @@ }; validator.toString = function (input) { + // The library validates strings only. Currently it coerces all input to a string, but this + // will go away in an upcoming major version change. Print a deprecation notice for now + if (typeof input !== 'string' && typeof console === 'object' && console + && typeof console.warn === 'function') { + console.warn('warning: you tried to validate a ' + typeof input + ' but this library ' + + '(github.com/chriso/validator.js) validates strings only. Please update your code ' + + 'as this will be an error soon.') + } if (typeof input === 'object' && input !== null) { if (typeof input.toString === 'function') { input = input.toString();