Eureka: RuleURL not validating correctly

Created on 24 Sep 2017  路  2Comments  路  Source: xmartlabs/Eureka

I am using the latest Eureka release 3.1.0 on Xcode 9 iOS 11.

This is the part of my code for the url row:

            <<< URLRow("website"){ row in
                row.title = NSLocalizedString("form view website title", value: "Website", comment: "")
                if let urlString = bookshelfAnnotation.bookshelf.webUrlString {
                    row.value = URL(string: urlString)
                }
                row.placeholder = NSLocalizedString("form view website placeholder", value: "URL", comment: "")
                row.add(rule: RuleURL(msg: NSLocalizedString("rule url", value: "Invalid URL", comment: "validation error url")))
            }

It does report this url as invalid: http://www.aidshilfe-koeln.de/index.php?id=10

Expected: This url is valid.

Most helpful comment

@ChaosCoder Thanks for fixing this! :)

All 2 comments

I created a little demo code to test this.

let regExpr = "((https|http)://)((\\w|-)+)(([.]|[/])((\\w|-)+))+"
let urlString = "http://www.aidshilfe-koeln.de/index.php?id=10"

let predicate = NSPredicate(format: "SELF MATCHES %@", regExpr)
if predicate.evaluate(with: urlString) {
    print("valid")
} else {
    print("invalid")
}

The regular expression is taken from your validation code here: https://github.com/xmartlabs/Eureka/blob/074ad432e697650087276e01c67bbb255e3ab1f4/Source/Validations/RuleRegExp.swift#L29

It does return the url as valid until ?id=10 is added.

The regular expression should be extended to support this.

@ChaosCoder Thanks for fixing this! :)

Was this page helpful?
0 / 5 - 0 ratings