Enable Button tests, fix AbsoluteLayout tests

This commit is contained in:
Panayot Cankov
2017-01-20 17:51:49 +02:00
parent e34b0f622c
commit 312a99667e
14 changed files with 139 additions and 162 deletions

View File

@@ -946,9 +946,13 @@ export function makeValidator<T>(...values: T[]): (value: any) => value is T {
return (value: any): value is T => set.has(value);
}
export function makeParser<T>(isValid: (value: any) => boolean, def: T): (value: any) => T {
export function makeParser<T>(isValid: (value: any) => boolean): (value: any) => T {
return value => {
const lower = value && value.toLowerCase();
return isValid(lower) ? lower : def;
if (isValid(lower)) {
return lower;
} else {
throw new Error("Invalid value: " + value);
}
}
}