feat(directives/forms): run tests in NodeJS

Closes #921
This commit is contained in:
Marc Laval
2015-03-09 17:41:49 +01:00
parent 7322ed721e
commit e8965656a4
6 changed files with 180 additions and 142 deletions
+5 -5
View File
@@ -1,18 +1,18 @@
import {isBlank, isPresent} from 'angular2/src/facade/lang';
import {List, ListWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
import {ControlGroup, Control} from 'angular2/forms';
import * as modelModule from './model';
export function required(c:Control) {
export function required(c:modelModule.Control) {
return isBlank(c.value) || c.value == "" ? {"required" : true} : null;
}
export function nullValidator(c:Control) {
export function nullValidator(c:modelModule.Control) {
return null;
}
export function compose(validators:List<Function>):Function {
return function(c:Control) {
return function(c:modelModule.Control) {
var res = ListWrapper.reduce(validators, (res, validator) => {
var errors = validator(c);
return isPresent(errors) ? StringMapWrapper.merge(res, errors) : res;
@@ -21,7 +21,7 @@ export function compose(validators:List<Function>):Function {
}
}
export function controlGroupValidator(c:ControlGroup) {
export function controlGroupValidator(c:modelModule.ControlGroup) {
var res = {};
StringMapWrapper.forEach(c.controls, (control, name) => {
if (c.contains(name) && isPresent(control.errors)) {