function checkFilesValidity(fileInputs) {

  function getFileError(file) {
    if (!file) {
      return ;
    }
    var size = parseInt(file.size);
    <% sizeLimit = FILE_SIZE_LIMIT %>;
    if (size > <%= sizeLimit.megabytes %>) {
      return "<%= I18n.t 'general.file_size_exceeded', file_size: sizeLimit %>";
    }
  };

  var isValid = true;
  _.each(fileInputs, function(fileInput) {
    var file = fileInput.files[0];
    var assetError = getFileError(file);
    var input = $(fileInput);
    input.closest('.form-group').removeClass('has-error');
    input.parent().find("[data-error='file-size']").remove();
    if (assetError) {
      input.closest('.form-group').addClass('has-error');
      input.parent().append(
        "<span class='help-block' data-error='file-size'>" + assetError + "</span>"
      );
      isValid = false;
    }
  });
  return isValid;
}