]>
Commit | Line | Data |
---|---|---|
49abbbbe C |
1 | import { FormControl } from '@angular/forms'; |
2 | ||
3 | export function validateHost(c: FormControl) { | |
447fde27 | 4 | // Thanks to http://stackoverflow.com/a/106223 |
ad4a8a1c | 5 | const HOST_REGEXP = new RegExp( |
447fde27 C |
6 | '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$' |
7 | ); | |
49abbbbe C |
8 | |
9 | return HOST_REGEXP.test(c.value) ? null : { | |
10 | validateHost: { | |
11 | valid: false | |
12 | } | |
13 | }; | |
14 | } |