ocadotechnology / hexagonjs

A modular, themable collection of components for modern browsers
https://www.hexagonjs.io
Apache License 2.0
51 stars 15 forks source link

Form Builder: Validation of files #224

Open rowan-simms opened 8 years ago

rowan-simms commented 8 years ago

eg to check the mime type is valid, or to check the format of the file

charlieTheBotDev commented 8 years ago

R.e. the mime type, you should be able to specify file types using the acceptedExtensions option (e.g. ['json']) however that just 'suggests' which file types can be uploaded, however for some operating systems (ubuntu?) it doesn't prevent you from selecting files of other types from the file upload dialog.

An option for validator should be added that is run for every file when selected. It should probably be async in case the validator needs to be server side, I'd suggest a signature something like:

validator: function (file, callback) {
  var isValid = // Boolean: file is valid
  callback(file, isValid)
}