making sure is passing a string to the codeMirror

codeMirror expectes a string.

Adding a formatter is not enough to make sure that the editor receives a
sting, since the ngModel can have multiple formatters registered.

For example, if we have a ui-codemirror textarea combined with required

<textarea name="myfield" ui-codemirror required
ng-model="vm.myfield"></textarea>

the ngModel will have tow formatters: the ui-codemirror and the
required.

When $scope.vm.myfield is undefined, the required formatter  return
undefined, and this will be the last formatter to run

Here is the exception we will get from codemirror

TypeError: Cannot call method 'split' of undefined
at window.CodeMirror.splitLines
(http://localhost:1995/Scripts/codemirror/codemirror.js:5570:38)
at window.CodeMirror.createObj.setValue
(http://localhost:1995/Scripts/codemirror/codemirror.js:4773:31)
at null.setValue
(http://localhost:1995/Scripts/codemirror/codemirror.js:4972:40)
at link.ngModel.$render
(http://localhost:1995/Scripts/ui-codemirror.js:81:26)
at Object.ngModelWatch
(http://localhost:1995/Scripts/angular.js:14504:14)
at Object.watchExpression (<anonymous>:754:29)
at Scope.$digest (http://localhost:1995/Scripts/angular.js:9897:47)
at Scope.$delegate.__proto__.$digest (<anonymous>:844:31)
at Scope.$apply (http://localhost:1995/Scripts/angular.js:10137:24)
at Scope.$delegate.__proto__.$apply (<anonymous>:855:30)

Here is the formatter of required directive (from angular sources)

var validator = function(value) {
        if (attr.required &&
(isEmpty(value) || value === false)) {

ctrl.$setValidity('required', false);
          return;
        } else
{
          ctrl.$setValidity('required', true);
          return
value;
        }
      };

      ctrl.$formatters.push(validator);

As we can se the formatter returns undefined if the value isEmpty