Skip to content

Commit

Permalink
#32: Improved validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Pagebakers committed Dec 30, 2014
1 parent 873e6e1 commit d509e43
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ Now Slingshot will validate the file before sending the authorization request to
```JavaScript
var uploader = new Slingshot.Upload("myFileUploads");

var isValid = uploader.validate(document.getElementById('input').files[0]);
if (isValid !== true) {
console.error(isValid);
var error = uploader.validate(document.getElementById('input').files[0]);
if (error) {
console.error(error);
}
```

Expand Down
4 changes: 2 additions & 2 deletions lib/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Slingshot.Upload = function (directive, metaData) {

/**
* @param {File} file
* @returns {Boolean|Error} Returns to on success, Error on failure.
* @returns {null|Error} Returns null on success, Error on failure.
*/

validate: function(file) {
Expand All @@ -73,7 +73,7 @@ Slingshot.Upload = function (directive, metaData) {
var validators = Slingshot.Validators,
restrictions = Slingshot.getRestrictions(directive);

return validators.authorize(context, file, metaData, restrictions);
validators.authorize(context, file, metaData, restrictions) && null;
} catch(error) {
return error;
}
Expand Down

0 comments on commit d509e43

Please sign in to comment.