AngularJS image size validation directive
if (attr.validateHeight != undefined) {
    ...
}

if (attr.validateWidth != undefined) {
    ...
}


The parts != undefined are unnecessary and just add noise to your code; JavaScript automatically checks to see if a conditional is true, or that it is not a false value. And undefined is a false value.



throw 'Invalid operator ' + operator + ' !';


Don't just throw a string as an error: create your own error object. I recommend calling it InvalidOperatorError as the reason why the error would be thrown is if an invalid operator was passed into your function.

Here is what the class would look like:

/*
* An error thrown if an invalid operator
* is passed into a function.
*
* @param(string) -- The error message
*/
function InvalidOperatorError(message) {
    this.name = "InvalidOperatorError";
    this.message = message;
}


Notice how I added documentation to this error? You should add this to your function validateImageSize so you can describe what each argument means and what the return means. Also, so you can describe the purpose of the function.

Now, you can use an instance of this class when you are throwing an error. Here is what that will look like:

throw new InvalidOperatorError('Invalid operator ' + operator + ' !');


See? Now you have a descriptive error.