Skip to content

Instantly share code, notes, and snippets.

@sebmck
Created February 16, 2013 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebmck/4965656 to your computer and use it in GitHub Desktop.
Save sebmck/4965656 to your computer and use it in GitHub Desktop.
module.exports = function(){
this.when('type', 'image', function(){
this.validates('imageSource', {
required: true,
restrict: ['web', 'computer']
});
this.when('imageSource', 'web', function(){
this.validates('imageUrl', {
alias: this.lang('submit#pictureUrl'),
required: true,
maxLength: 120,
placeholder: this.lang('submit#pictureUrlPlaceholder'),
remoteFile: 'imageFile'
});
});
this.validatesFile('imageFile', {
alias: this.lang('submit#pictureFile'),
required: true,
maxSize: 4..megabytes,
type: 'image',
image: {
restrictFormat: ['jpeg', 'jpg', 'png', 'gif'],
maxHeight: 10000,
maxWidth: 5000,
minWidth: 200,
minHeight: 200,
resize: {
width: 820,
height: 2000
}
}
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment