mirror of
https://github.com/valitydev/koffing.git
synced 2024-11-06 09:15:20 +00:00
FE-652: URL validation improvement (#217)
This commit is contained in:
parent
0065279812
commit
f25d691ab1
@ -36,6 +36,7 @@
|
||||
"rxjs": "~5.5.2",
|
||||
"suggestions-jquery": "~17.5.0",
|
||||
"uuid": "~3.1.0",
|
||||
"validator": "~10.7.0",
|
||||
"xlsx-style": "~0.8.13",
|
||||
"zone.js": "~0.8.5"
|
||||
},
|
||||
@ -48,6 +49,7 @@
|
||||
"@types/lodash": "~4.14.66",
|
||||
"@types/node": "~8.0.3",
|
||||
"@types/uuid": "~3.0.0",
|
||||
"@types/validator": "~9.4.1",
|
||||
"codelyzer": "~4.0.1",
|
||||
"copy-webpack-plugin": "~4.0.1",
|
||||
"css-loader": "~0.28.4",
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { Injectable } from '@angular/core';
|
||||
import * as uuid from 'uuid/v4';
|
||||
import { isURL } from 'validator';
|
||||
|
||||
import { ShopCreation, ShopDetails, ShopLocationUrl } from 'koffing/backend';
|
||||
|
||||
@ -17,7 +18,7 @@ export class ShopFormService {
|
||||
return this.fb.group({
|
||||
url: ['', [
|
||||
Validators.required,
|
||||
Validators.pattern(/^(ftp|http|https)+(:\/\/)+([a-zа-я0-9]+(-[a-zа-я0-9]+)*\.)+[a-zа-я]{2,}$/)
|
||||
(c: AbstractControl) => isURL(c.value, {protocols: ['http', 'https'], require_protocol: true}) ? null : {isURL: true}
|
||||
]],
|
||||
name: ['', [
|
||||
Validators.required,
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
import { FormBuilder, FormControl, FormGroup, Validators, AbstractControl } from '@angular/forms';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { forEach, mapValues, map } from 'lodash';
|
||||
import { isURL } from 'validator';
|
||||
|
||||
import { EventTypePresent } from '../create-webhook/event-type-present';
|
||||
import { WebhooksService } from 'koffing/backend/webhooks.service';
|
||||
@ -86,7 +87,7 @@ export class CreateWebhookService {
|
||||
return this.fb.group({
|
||||
url: ['', [
|
||||
Validators.required,
|
||||
Validators.pattern(/^(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*))$/)
|
||||
(c: AbstractControl) => isURL(c.value, {protocols: ['http', 'https'], require_protocol: true}) ? null : {isURL: true}
|
||||
]],
|
||||
eventTypes: this.fb.group(this.prepareEventTypesGroup(this.eventTypes)),
|
||||
topic: 'InvoicesTopic'
|
||||
|
Loading…
Reference in New Issue
Block a user