feat(StatusQ.Controls.Validators): introduce `StatusUrlValidator`
This commit is contained in:
parent
dee9f43761
commit
a91558655c
|
@ -0,0 +1,15 @@
|
|||
import StatusQ.Core.Utils 0.1
|
||||
import StatusQ.Controls 0.1
|
||||
|
||||
StatusValidator {
|
||||
|
||||
name: "url"
|
||||
|
||||
errorMessage: "Please enter a valid URL"
|
||||
|
||||
validate: function (value) {
|
||||
return Utils.isURL(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -6,4 +6,5 @@ StatusAsyncValidator 0.1 StatusAsyncValidator.qml
|
|||
StatusAsyncEnsValidator 0.1 StatusAsyncEnsValidator.qml
|
||||
StatusMinLengthValidator 0.1 StatusMinLengthValidator.qml
|
||||
StatusMaxLengthValidator 0.1 StatusMaxLengthValidator.qml
|
||||
StatusUrlValidator 0.1 StatusUrlValidator.qml
|
||||
StatusValidator 0.1 StatusValidator.qml
|
||||
|
|
|
@ -27,6 +27,10 @@ QtObject {
|
|||
return isEmail || isDomain || (inputValue.startsWith("@") && inputValue.length > 1)
|
||||
}
|
||||
|
||||
function isURL(text) {
|
||||
return (/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}(\.[a-zA-Z0-9()]{1,6})?\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/.test(text))
|
||||
}
|
||||
|
||||
function uuid() {
|
||||
return Date.now().toString(36) + Math.random().toString(36).substr(2, 5)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue