var readChunk = require('read-chunk');
var imageType = require('image-type');

exports = module.exports = {
  validator: function(val) {
    if (val) {
      var buffer = readChunk.sync(val, 0, 12);

      return imageType(buffer) !== null;
    }

    return true;
  },
  message: '<%= propertyName %> must be an image.'
};

var readChunk = require('read-chunk');
var imageType = require('image-type');
var _ = require('lodash');

exports = module.exports = {
  validator: function(val) {
    if (val) {
      if (_.isObject(val)) {
        val = val.path;
      }

      var buffer = readChunk.sync(val, 0, 12);

      return imageType(buffer) !== null;
    }

    return true;
  },
  message: '<%= propertyName %> must be an image.'
};

Check if given value is object (for image rule), if its an object then get the path