Взято из Изменение встроенных валидаторов вам нужно отделить строку от ввода и сделать недействительной форму, если одна из подстрок недействительна. Это просто наивный пример для начала:
Plunk
https://plnkr.co/edit/ABQg3zba7f9sPei4?p=preview
JS
var app = angular.module('customEmailValidation',[]);
app.controller('MainCtrl', ['$scope', function($scope){
$scope.email = '';
$scope.submitForm = function(){
}
}]);
app.directive('multimail', function() {
var EMAIL_REGEXP = /\S+@\S+\.\S+/i;
return {
require: '?ngModel',
link: function(scope, elm, attrs, ctrl) {
// only apply the validator if ngModel is present and AngularJS has added the email validator
if (ctrl && ctrl.$validators.email) {
// this will overwrite the default AngularJS email validator
ctrl.$validators.email = function(modelValue) {
if (ctrl.$isEmpty(modelValue)) {
return true;
}
var mails = [];
if (modelValue.indexOf(' ') > 0) {
mails = modelValue.split(' ');
} else {
mails.push(modelValue);
}
var valid = true;
for(var i = 0; i < mails.length; i++) {
if (!EMAIL_REGEXP.test(mails[i])) {
valid = false;
}
}
return valid;
};
}
}
};
});
HTML
<body ng-app="customEmailValidation" ng-cloak>
<div ng-controller="MainCtrl">
<form name="myForm" ng-submit="submitForm()">
<label>Email Address</label>
<input
multimail
type="email"
id="EmailAddresses"
required
name="EmailAddresses"
ng-model="email"
name="email"
placeholder="yourname@organization.org name@organization.org">
<div class="error" ng-show="!!myForm.email.$error">
<p ng-show="myForm.email.$error.required">This is a required field</p>
<p ng-show="myForm.email.$error.email">Your email address is invalid</p>
</div>
<button type="sumbit">Submit</button>
</form>
</div>
</body>