Validator.js: isObject validator

Created on 6 May 2014  路  3Comments  路  Source: validatorjs/validator.js

Would be nice to have an isObjectvalidator. For example this could be used in validation functions after a request has been parsed by node.js.

If you're interested I could create a pull request for you.

Most helpful comment

Even tho this is a string validation library, I honestly feel this should be added.
Why not parse an object to string (JSON.stringify) and check for valid JSON?

All 3 comments

This has been brought up before but rejected since it's a string validation library only. You can always mixin your own functions to the validator object

validator.isObject = function (obj) {
    return typeof obj === 'object';
};

Even tho this is a string validation library, I honestly feel this should be added.
Why not parse an object to string (JSON.stringify) and check for valid JSON?

I agree that it would be useful

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mum-never-proud picture mum-never-proud  路  4Comments

AnandChowdhary picture AnandChowdhary  路  3Comments

AtomicBorg picture AtomicBorg  路  3Comments

malkhuzayyim picture malkhuzayyim  路  4Comments

Maxreglez picture Maxreglez  路  3Comments