Swiftpack.co - Package - RougeWare/Swift-Special-String

SpecialString

Ever need a string but also wish it weren't a String type? Like if you got some unsafe user input and never want to accidentally put it in a SQL query unsanitized? Of if you got a local ID and didn't want to mix it up with a remote ID?

SpecialString achieves just this. In all but name, it acts like a string. However, it's protected by Swift's powerful type system so that it can never be mistaken as something else.

Premade Special Strings

This package contains some premade special strings for common usages:

  • UnsafeUserInput - Unsafe user input. It must be sanitized before it can be safely used.
  • SanitizedUserInput - User input which has gone through some process and can now be deemed safe to use.
  • Password - A password. It must never be serialized as a plaintext string.

Identifiers

Identifiers are very commonly strings, so they are perfect use cases for SpecialString! However, because each identifier is inherently tied to the service in which it identifies something, this package does not define any. Instead, you should define a new special type for each remote service, like LocalImageIdentifier, GoogleDriveItemIdentifier, or BrowserSessionIdentifier.

EssentiallyAString

This package also includes the handy protocol EssentiallyAString, which helps you make types which are essentially strings. This greatly improves the ergonomics of SpecialString, letting you use it in most of the ways a String can be used.

Feel free to use EssentiallyAString for other things!

Github

link
Stars: 0
Help us keep the lights on

Dependencies

Used By

Total: 0

Releases

1.0.0 - Oct 6, 2019

  • SpecialString - Leverage Swift's powerful type system to make sure no two kinds of string are mixed up
  • EssentiallyAString - The backbone of the handy ergonomics of SpecialString
  • Premade special strings
    • UnsafeUserInput - Unsafe user input. It must be sanitized before it can be safely used.
    • SanitizedUserInput - User input which has gone through some process and can now be deemed safe to use.
    • Password - A password. It must never be serialized as a plaintext string.