@@ -193,7 +193,7 @@ func validateEnum(_ values: [Any]) -> (_ value: Any) -> ValidationResult {
193193func validateLength( _ comparitor: @escaping ( ( Int , Int ) -> ( Bool ) ) , length: Int , error: String ) -> ( _ value: Any ) -> ValidationResult {
194194 return { value in
195195 if let value = value as? String {
196- if !comparitor( value. characters . count, length) {
196+ if !comparitor( value. count, length) {
197197 return . invalid( [ error] )
198198 }
199199 }
@@ -207,7 +207,7 @@ func validatePattern(_ pattern: String) -> (_ value: Any) -> ValidationResult {
207207 if let value = value as? String {
208208 let expression = try ? NSRegularExpression ( pattern: pattern, options: NSRegularExpression . Options ( rawValue: 0 ) )
209209 if let expression = expression {
210- let range = NSMakeRange ( 0 , value. characters . count)
210+ let range = NSMakeRange ( 0 , value. count)
211211 if expression. matches ( in: value, options: NSRegularExpression . MatchingOptions ( rawValue: 0 ) , range: range) . count == 0 {
212212 return . invalid( [ " ' \( value) ' does not match pattern: ' \( pattern) ' " ] )
213213 }
@@ -344,7 +344,7 @@ func validateProperties(_ properties: [String:Validator]?, patternProperties: [S
344344 do {
345345 let expression = try NSRegularExpression ( pattern: pattern, options: NSRegularExpression . Options ( rawValue: 0 ) )
346346 let keys = value. keys. filter {
347- ( key: String ) in expression. matches ( in: key, options: NSRegularExpression . MatchingOptions ( rawValue: 0 ) , range: NSMakeRange ( 0 , key. characters . count) ) . count > 0
347+ ( key: String ) in expression. matches ( in: key, options: NSRegularExpression . MatchingOptions ( rawValue: 0 ) , range: NSMakeRange ( 0 , key. count) ) . count > 0
348348 }
349349
350350 allKeys. addObjects ( from: Array ( keys) )
@@ -400,7 +400,7 @@ func validateDependencies(_ key: String, dependencies: [String]) -> (_ value: An
400400func validateIPv4( _ value: Any ) -> ValidationResult {
401401 if let ipv4 = value as? String {
402402 if let expression = try ? NSRegularExpression ( pattern: " ^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) \\ .(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) \\ .(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) \\ .(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$ " , options: NSRegularExpression . Options ( rawValue: 0 ) ) {
403- if expression. matches ( in: ipv4, options: NSRegularExpression . MatchingOptions ( rawValue: 0 ) , range: NSMakeRange ( 0 , ipv4. characters . count) ) . count == 1 {
403+ if expression. matches ( in: ipv4, options: NSRegularExpression . MatchingOptions ( rawValue: 0 ) , range: NSMakeRange ( 0 , ipv4. count) ) . count == 1 {
404404 return . valid
405405 }
406406 }
@@ -429,10 +429,10 @@ func validateURI(_ value:Any) -> ValidationResult {
429429 // Using the regex from http://blog.dieweltistgarnichtso.net/constructing-a-regular-expression-that-matches-uris
430430
431431 if let expression = try ? NSRegularExpression ( pattern: " ((?<= \\ ()[A-Za-z][A-Za-z0-9 \\ + \\ . \\ -]*:([A-Za-z0-9 \\ . \\ -_~:/ \\ ?# \\ [ \\ ]@! \\ $&' \\ ( \\ ) \\ * \\ +,;=]|%[A-Fa-f0-9]{2})+(?= \\ )))|([A-Za-z][A-Za-z0-9 \\ + \\ . \\ -]*:([A-Za-z0-9 \\ . \\ -_~:/ \\ ?# \\ [ \\ ]@! \\ $&' \\ ( \\ ) \\ * \\ +,;=]|%[A-Fa-f0-9]{2})+) " , options: NSRegularExpression . Options ( rawValue: 0 ) ) {
432- let result = expression. matches ( in: uri, options: NSRegularExpression . MatchingOptions ( rawValue: 0 ) , range: NSMakeRange ( 0 , uri. characters . count) )
432+ let result = expression. matches ( in: uri, options: NSRegularExpression . MatchingOptions ( rawValue: 0 ) , range: NSMakeRange ( 0 , uri. count) )
433433 if result. count == 1 {
434434 let foundRange = result [ 0 ] . range
435- if foundRange. location == 0 && foundRange. length == uri. characters . count {
435+ if foundRange. location == 0 && foundRange. length == uri. count {
436436 return . valid
437437 }
438438 }
0 commit comments