7 lines
331 B
TypeScript
7 lines
331 B
TypeScript
import {AbstractControl} from '@angular/forms';
|
|
|
|
export function URLFormatValidator(control: AbstractControl): {[key: string]: any} | null {
|
|
const valid = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/.test(control.value);
|
|
return valid ? null : {'invalidURLFormat': {value: control.value}};
|
|
}
|