Merge pull request #75 from ivopisarovic/master

The whole string needs to match number format.
This commit is contained in:
Jeff Potter 2016-02-03 21:57:19 -07:00
commit 86e735397d
1 changed files with 2 additions and 2 deletions

View File

@ -17,7 +17,7 @@ public class FloatRule:Rule {
}
public func validate(value: String) -> Bool {
let regex = try? NSRegularExpression(pattern: "[-+]?(\\d*[.])?\\d+", options: [])
let regex = try? NSRegularExpression(pattern: "^[-+]?(\\d*[.])?\\d+$", options: [])
if let regex = regex {
let match = regex.numberOfMatchesInString(value, options: [], range: NSRange(location: 0, length: value.characters.count))
return match == 1
@ -28,4 +28,4 @@ public class FloatRule:Rule {
public func errorMessage() -> String {
return message
}
}
}