angular.module('app').directive("validateBitcoinAddress", function() {
    return {
        require: 'ngModel',
        link: function(scope, ele, attrs, ctrl) {

            ctrl.$parsers.unshift(function(value) {

                // test and set the validity after update.
                var valid = window.bitcoinAddress.validate(value);
                ctrl.$setValidity('validateBitcoinAddress', valid);

                // if it's valid, return the value to the model,
                // otherwise return undefined.
                return valid ? value : undefined;
            });

            ctrl.$formatters.unshift(function(value) {
                // validate.
                ctrl.$setValidity('validateBitcoinAddress', window.bitcoinAddress.validate(value));

                // return the value or nothing will be written to the DOM.
                return value;
            });


        }
    };

});

@@ -211,68 +211,8 @@
 e) %7B
-%0A%0A                // test and set the validity after update.
 %0A   
@@ -346,121 +346,8 @@
 id);
-%0A%0A                // if it's valid, return the value to the model,%0A                // otherwise return undefined.
 %0A   
@@ -485,80 +485,19 @@
     
-// validate.%0A                ctrl.$setValidity('validateBitcoinAddress',
+var valid =
  win
@@ -530,19 +530,17 @@
 e(value)
-);%0A
+;
 %0A       
@@ -552,66 +552,59 @@
     
-// return the value or nothing will be written to the DOM.
+ctrl.$setValidity('validateBitcoinAddress', valid);
 %0A   

Clean up comments and validity check