aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/forms/form-validators/host.validator.ts
blob: c18a35f9bc8f8713e1062991904081eb317be5c1 (plain) (blame)
1
2
3
4
5
6
7
8
export function validateHost (value: string) {
  // Thanks to http://stackoverflow.com/a/106223
  const HOST_REGEXP = new RegExp(
    '^(([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])$'
  )

  return HOST_REGEXP.test(value)
}