Skip to content

Commit

Permalink
Merge pull request #163 from niscy-eudiw/main
Browse files Browse the repository at this point in the history
Added extension function to check for String nullability and emptiness.
  • Loading branch information
stzouvaras authored Sep 9, 2024
2 parents 0049e34 + da3af25 commit f5342d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,11 @@ public extension String {
return data.base64EncodedString()
}
}

public extension String? {

func isNullOrEmpty() -> Bool {
return self == nil || self?.isEmpty == true
}

}
6 changes: 3 additions & 3 deletions Modules/logic-business/Sources/Validator/FormValidator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ final class FormValidatorImpl: FormValidator {
return false
}

if shouldValidateHost && (components.host == nil || components.host?.isEmpty == true) {
if shouldValidateHost && components.host.isNullOrEmpty() {
return false
}

if shouldValidateSchema && (components.scheme == nil || components.scheme?.isEmpty == true) {
if shouldValidateSchema && components.scheme.isNullOrEmpty() {
return false
}

if shouldValidateQuery && (components.query == nil || components.query?.isEmpty == true) {
if shouldValidateQuery && components.query.isNullOrEmpty() {
return false
}

Expand Down

0 comments on commit f5342d7

Please sign in to comment.