mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-20 12:00:53 +08:00
Merge pull request #4594 from billccn/master
Made the signature of INgModelController.$validators more precise
This commit is contained in:
Regular → Executable
+27
-1
@@ -702,4 +702,30 @@ module locationTests {
|
||||
$location.path() == '/foo/bar'
|
||||
$location.url() == '/foo/bar?x=y'
|
||||
$location.absUrl() == 'http://example.com/#!/foo/bar?x=y'
|
||||
}
|
||||
}
|
||||
|
||||
// NgModelController
|
||||
function NgModelControllerTyping() {
|
||||
var ngModel: angular.INgModelController;
|
||||
var $http: angular.IHttpService;
|
||||
var $q: angular.IQService;
|
||||
|
||||
// See https://docs.angularjs.org/api/ng/type/ngModel.NgModelController#$validators
|
||||
ngModel.$validators['validCharacters'] = function(modelValue, viewValue) {
|
||||
var value = modelValue || viewValue;
|
||||
return /[0-9]+/.test(value) &&
|
||||
/[a-z]+/.test(value) &&
|
||||
/[A-Z]+/.test(value) &&
|
||||
/\W+/.test(value);
|
||||
};
|
||||
|
||||
ngModel.$asyncValidators['uniqueUsername'] = function(modelValue, viewValue) {
|
||||
var value = modelValue || viewValue;
|
||||
return $http.get('/api/users/' + value).
|
||||
then(function resolved() {
|
||||
return $q.reject('exists');
|
||||
}, function rejected() {
|
||||
return true;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -524,11 +524,11 @@ declare module angular {
|
||||
}
|
||||
|
||||
interface IModelValidators {
|
||||
[index: string]: (...args: any[]) => boolean;
|
||||
[index: string]: (modelValue: any, viewValue: string) => boolean;
|
||||
}
|
||||
|
||||
interface IAsyncModelValidators {
|
||||
[index: string]: (...args: any[]) => IPromise<boolean>;
|
||||
[index: string]: (modelValue: any, viewValue: string) => IPromise<any>;
|
||||
}
|
||||
|
||||
interface IModelParser {
|
||||
|
||||
Reference in New Issue
Block a user