String
extension String
-
PowerUpSwift: A
mutatingcounterpart ofsantized().Declaration
Swift
public mutating func sanitize() -
PowerUpSwift: Returns the trimmed valueof the String by:
- removing all the white spaces and white new lines around
- replacing two or more spaces inside with a single space
- replacing three or more new lines inside with two new lines
It should just work! Trust PowerUpSwift. 😂😂😂
Declaration
Swift
public func sanitized() -> String -
PowerUpSwift: Checks if the String is a valid email and returns a
Boolvalue.Declaration
Swift
public var isValidEmail: Bool { get } -
PowerUpSwift: Returns the reversed value of
isValidEmailso it feels more natural to write than using an exclamation point.Declaration
Swift
public var isNotValidEmail: Bool { get } -
PowerUpSwift: Returns the reversed value of
isEmptyso it feels more natural to write than using an exclamation point.Declaration
Swift
public var isNotEmpty: Bool { get } -
PowerUpSwift: Uses the very
Stringas the key in the main bundle’s localizable resources and returns the value.Declaration
Swift
public var localized: String { get } -
PowerUpSwift: Uses the very
Stringas the key in the specified bundle’s localizable resources and returns the value.Declaration
Swift
public func localized(in bundle: Bundle?, comment: String = "") -> String -
PowerUpSwift: Checks if the String is a valid IP address and returns a
Boolvalue.Declaration
Swift
public var isValidIP: Bool { get } -
PowerUpSwift: Returns the reversed value of
isValidIPso it feels more natural to write than using an exclamation point.Declaration
Swift
public var isNotValidIP: Bool { get } -
PowerUpSwift: Checks if the String is a valid mac address and returns a
Boolvalue.Declaration
Swift
public var isValidMAC: Bool { get } -
PowerUpSwift: Returns the reversed value of
isValidMACso it feels more natural to write than using an exclamation point.Declaration
Swift
public var isNotValidMAC: Bool { get } -
PowerUpSwift: Returns the
Dictionaryform of theStringif the format is valid ornilif invalid.Declaration
Swift
public var json: [String : Any]? { get } -
PowerUpSwift: Parses the
Stringand returns the payloadDictionaryif it’s a valid JWT.Declaration
Swift
public var jwtPayload: [String : Any]? { get }
String Extension Reference