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