2022-02-08 13:31:36 +01:00
|
|
|
import {ValidatorFn, Validators} from "@angular/forms";
|
|
|
|
|
2019-01-18 18:03:45 +01:00
|
|
|
export enum ValidationType {
|
|
|
|
None = 0,
|
2022-02-08 13:31:36 +01:00
|
|
|
Required = 1,
|
|
|
|
URL = 2
|
|
|
|
}
|
|
|
|
|
|
|
|
export class ValidatorURL {
|
|
|
|
|
|
|
|
public static regex = 'https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.' +
|
|
|
|
'[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.' +
|
|
|
|
'[a-zA-Z0-9]+\.[^\s]{2,}';
|
|
|
|
|
|
|
|
public static get validator(): ValidatorFn {
|
|
|
|
return Validators.pattern(ValidatorURL.regex);
|
|
|
|
}
|
2019-01-18 18:03:45 +01:00
|
|
|
}
|