aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/forms/form-validators/host.validator.ts
blob: 9cb46d36133fe742e975704b73585f15c1ccd314 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
import { FormControl } from '@angular/forms';

export function validateHost(c: FormControl) {
  let HOST_REGEXP = new RegExp('^(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$');

  return HOST_REGEXP.test(c.value) ? null : {
    validateHost: {
      valid: false
    }
  };
}