]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/shared/forms/form-validators/host.validator.ts
Use typescript standard and lint all files
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / forms / form-validators / host.validator.ts
1 import { FormControl } from '@angular/forms'
2
3 export function validateHost (c: FormControl) {
4 // Thanks to http://stackoverflow.com/a/106223
5 const HOST_REGEXP = new RegExp(
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 )
8
9 return HOST_REGEXP.test(c.value) ? null : {
10 validateHost: {
11 valid: false
12 }
13 }
14 }