isSimpleValidator.js 454 B

12345678910111213141516171819202122
  1. 'use strict';
  2. /*!
  3. * Determines if `arg` is a flat object.
  4. *
  5. * @param {Object|Array|String|Function|RegExp|any} arg
  6. * @api private
  7. * @return {Boolean}
  8. */
  9. module.exports = function isSimpleValidator(obj) {
  10. const keys = Object.keys(obj);
  11. let result = true;
  12. for (let i = 0, len = keys.length; i < len; ++i) {
  13. if (typeof obj[keys[i]] === 'object' && obj[keys[i]] !== null) {
  14. result = false;
  15. break;
  16. }
  17. }
  18. return result;
  19. };