Improve isUrl validator

Allowing to check http(s) and format
without domain like http://localhost:8080

Signed-off-by: alexfront <alex.andreev.email@gmail.com>
Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
alexfront authored and Lauri Nevala committed 2020-08-18 12:02:26 +03:00
1 parent bc339e44b6
commit 877fe18b75
1 file changed
+1 -1
@@ -38,7 +38,7 @@ export const isNumber: Validator = {
export const isUrl: Validator = {
condition: ({ type }) => type === "url",
message: () => _i18n._(t`Wrong url format`),
validate: value => !!value.match(/^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/),
validate: value => !!value.match(/^http(s)?:\/\/\w+(\.\w+)*(:[0-9]+)?\/?(\/[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]*)*$/),
};
export const minLength: Validator = {