forked from angular/quickstart
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidators.js
More file actions
89 lines (87 loc) · 3.14 KB
/
Copy pathvalidators.js
File metadata and controls
89 lines (87 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
System.register(["angular2/src/facade/lang", "angular2/src/facade/collection", "./model"], function($__export) {
"use strict";
var isBlank,
isPresent,
List,
ListWrapper,
StringMapWrapper,
modelModule,
Validators;
return {
setters: [function($__m) {
isBlank = $__m.isBlank;
isPresent = $__m.isPresent;
}, function($__m) {
List = $__m.List;
ListWrapper = $__m.ListWrapper;
StringMapWrapper = $__m.StringMapWrapper;
}, function($__m) {
modelModule = $__m;
}],
execute: function() {
Validators = $__export("Validators", (function() {
var Validators = function Validators() {};
return ($traceurRuntime.createClass)(Validators, {}, {
required: function(c) {
return isBlank(c.value) || c.value == "" ? {"required": true} : null;
},
nullValidator: function(c) {
return null;
},
compose: function(validators) {
return function(c) {
var res = ListWrapper.reduce(validators, (function(res, validator) {
var errors = validator(c);
return isPresent(errors) ? StringMapWrapper.merge(res, errors) : res;
}), {});
return StringMapWrapper.isEmpty(res) ? null : res;
};
},
group: function(c) {
var res = {};
StringMapWrapper.forEach(c.controls, (function(control, name) {
if (c.contains(name) && isPresent(control.errors)) {
Validators._mergeErrors(control, res);
}
}));
return StringMapWrapper.isEmpty(res) ? null : res;
},
array: function(c) {
var res = {};
ListWrapper.forEach(c.controls, (function(control) {
if (isPresent(control.errors)) {
Validators._mergeErrors(control, res);
}
}));
return StringMapWrapper.isEmpty(res) ? null : res;
},
_mergeErrors: function(control, res) {
StringMapWrapper.forEach(control.errors, (function(value, error) {
if (!StringMapWrapper.contains(res, error)) {
res[error] = [];
}
ListWrapper.push(res[error], control);
}));
}
});
}()));
Object.defineProperty(Validators.required, "parameters", {get: function() {
return [[modelModule.Control]];
}});
Object.defineProperty(Validators.nullValidator, "parameters", {get: function() {
return [[assert.type.any]];
}});
Object.defineProperty(Validators.compose, "parameters", {get: function() {
return [[assert.genericType(List, Function)]];
}});
Object.defineProperty(Validators.group, "parameters", {get: function() {
return [[modelModule.ControlGroup]];
}});
Object.defineProperty(Validators.array, "parameters", {get: function() {
return [[modelModule.ControlArray]];
}});
}
};
});
//# sourceMappingURL=src/forms/validators.map
//# sourceMappingURL=../../src/forms/validators.js.map