feat(StatusQ.Controls.Validators): introduce `StatusAddressValidator`
This commit is contained in:
parent
af8d2036f3
commit
f979011323
|
@ -0,0 +1,13 @@
|
|||
import StatusQ.Controls 0.1
|
||||
import StatusQ.Core.Utils 0.1
|
||||
|
||||
StatusValidator {
|
||||
name: "address"
|
||||
|
||||
errorMessage: "Please enter a valid address."
|
||||
|
||||
validate: function (t) {
|
||||
return Utils.isValidAddress(t) ? true : { actual: t }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
module StatusQ.Controls.Validators
|
||||
|
||||
StatusAddressValidator 0.1 StatusAddressValidator.qml
|
||||
StatusValidator 0.1 StatusValidator.qml
|
||||
StatusMinLengthValidator 0.1 StatusMinLengthValidator.qml
|
||||
StatusMaxLengthValidator 0.1 StatusMaxLengthValidator.qml
|
||||
|
|
|
@ -14,6 +14,10 @@ QtObject {
|
|||
}
|
||||
return returnPos;
|
||||
}
|
||||
function isValidAddress(inputValue) {
|
||||
return inputValue !== "0x" && /^0x[a-fA-F0-9]{40}$/.test(inputValue)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue