1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-23 14:40:34 +01:00

Fixed regex matching in GUIValidators

This commit is contained in:
dpad85 2017-02-09 15:06:45 +01:00
parent a623810518
commit b9ec691dcd

View file

@ -10,8 +10,8 @@ import scala.util.matching.Regex
object GUIValidators {
val hostRegex = """([a-fA-F0-9]+)@([a-zA-Z0-9\.\-_]+):([0-9]+)""".r
val amountRegex = """\d+""".r
val amountDecRegex = """\d+|\d+\.[\d]{1,3}""".r // accepts 3 decimals at most
val paymentRequestRegex = """[a-zA-Z0-9]+:[a-zA-Z0-9]+:[a-zA-Z0-9]+""".r
val amountDecRegex = """(\d+)|(\d+\.[\d]{1,3})""".r // accepts 3 decimals at most
val paymentRequestRegex = """([a-zA-Z0-9]+):([a-zA-Z0-9]+):([a-zA-Z0-9]+)""".r
val hexRegex = """[0-9a-fA-F]+""".r
/**
@ -26,12 +26,8 @@ object GUIValidators {
*/
def validate(field: String, validatorLabel: Label, validatorMessage: String, regex: Regex): Boolean = {
return field match {
case regex() => {
return validate(validatorLabel, validatorMessage, true)
}
case _ => {
return validate(validatorLabel, validatorMessage, false)
}
case regex(_*) => validate(validatorLabel, validatorMessage, true)
case _ => validate(validatorLabel, validatorMessage, false)
}
}