Merge pull request #75 from ivopisarovic/master
The whole string needs to match number format.
This commit is contained in:
commit
86e735397d
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue