What's New

1.1.3 - `EssentiallyAString` (and therefore `SpecialString`) now conforms to `Codable`

2019-10-26T22:29:51Z

Now, both EssentiallyAString and SpecialString conform to Codable, making it easy to encode and decode your special string, or anything else which is essentially just a string


Patch Changes

  • 1.1.3
    • Added a dynamic library product whose name is a valid bundle identifier
    • Deprecated previous dynamic library product because its name caused problems when submitting to the App Store
  • 1.1.2
    • Added alternative dynamic library product
  • 1.1.1
    • Added dual licenses

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!

Description

  • Swift Tools 5.1.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sun Oct 20 2024 16:08:05 GMT-0900 (Hawaii-Aleutian Daylight Time)