Created
December 18, 2017 16:06
-
-
Save Winchariot/753d3cbfadf6a71a995699946b6c0790 to your computer and use it in GitHub Desktop.
Validate nonempty string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
//Validate both that a string is nonempty and that it contains something besides whitespace. | |
// Useful for driving things like enabling a submit button only when a user has entered (meaningful) text | |
var isVisuallyEmpty: Bool { | |
return self.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment