I am trying to use validator.isNull() with a var that I have tried to instantiate as null, undefined or as new String(null), but none of these cases seem to work with isNull, I am always receiving the same error:
validator deprecated you tried to validate a object but this library (validator.js) validates strings only. Please update your code as this will be an error soon.
How can this be coerced correctly, or should this function be modified or removed in light of the String only validation?
Looking at the source for isNull would suggest a better name name and description would be isEmpty seeing as this is a simple length check.
The library validates strings only. Automatic coercion of input to a string was deprecated and then removed in the latest release. Passing anything that isn't a string will now result in an error.
isNull() should have probably been renamed to isEmpty() (or similar) in that release. Previously null and undefined input would have been coerced to an empty string; now all the validator does is check if the input string has a length of zero. I'll update the README so that this is clear.
I only just bumped v4 to v5 so I'm not prepared to make a breaking change to rename it.