SpecificationPattern alternatives and similar libraries
Based on the "Utility" category.
Alternatively, view SpecificationPattern alternatives based on common mentions on social networks and blogs.
-
SwifterSwift
A handy collection of more than 500 native Swift extensions to boost your productivity. -
SwiftGen
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs! -
SwiftGen-Storyboard
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs! -
SwiftLinkPreview
DISCONTINUED. It makes a preview from an URL, grabbing all the information such as title, relevant texts and images. -
Playbook
📘A library for isolated developing UI components and automatically taking snapshots of them. -
BetterSafariView
A better way to present a SFSafariViewController or start a ASWebAuthenticationSession in SwiftUI. -
SwiftPlantUML
A command-line tool and Swift Package for generating class diagrams powered by PlantUML -
Pythonic.swift
DISCONTINUED. Pythonic tool-belt for Swift – a Swift implementation of selected parts of Python standard library.
CodeRabbit: AI Code Reviews for Developers

* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of SpecificationPattern or a related project?
README
SpecificationPattern
The Specification design pattern implemented in swift for iOS/OSX.
In computer programming, the specification pattern is a particular software design pattern, whereby business rules can be recombined by chaining the business rules together using boolean logic.
Source: wikipedia.org
Requirements
- Xcode 7.0 beta 4 (7A165t)
- Swift 2
- iOS 9.0+ / Mac OS X 10.10+
Usage
Chain two specifications into a single specification.
let s0 = RegularExpressionSpecification(pattern: "hello.*world")
let s1 = CountSpecification.between(20, 30)
let spec = s0 & s1
spec == "42"
# false, doesn't satify s0 and s1
spec == "hello world"
# false, s0 is satisfied, but not s1
spec == "say hello to the world today"
# true
Useful classes
Beyond the specification pattern itself, this project provides the following iOS/OSX specifications
- CharacterSetSpecification - for ensuring all characters in a string are of a certain kind, eg. all digits
- CountSpecification - for ensuring that a string/array isn't too long or short
- EmailSpecification - decide if an email is valid or not
- PredicateSpecification - if you don't want to subclass you can use this and instead provide a closure
- RegularExpressionSpecification - useful for string matching
Operators
And operator
Use the &
operator when two specifications both must be satisfied.
Or operator
Use the |
operator when one of two specifications must be satisfied.
Not operator
Use the !
operator when a specifications must not be satisfied.
Equal operator
Use the ==
operator to check if a candidate object satisfies the specification.
Not equal operator
Use the !=
operator to check if a candidate object doesn't satisfy the specification.
Example - Invoice handling
In the following example, we are retrieving invoices and sending them to a collection agency if
- they are overdue,
- notices have been sent, and
- they are not already with the collection agency.
This example is meant to show the end result of how the logic is 'chained' together.
let overDue = OverDueSpecification()
let noticeSent = NoticeSentSpecification()
let inCollection = InCollectionSpecification()
// example of specification pattern logic chaining
let spec = overDue & noticeSent & !inCollection
for invoice in Service.invoices() where spec == invoice {
invoice.sendToCollection()
}
Sample project - Live text validation
[](example0.gif)
The coloring are like this:
- Red, when the text neither can be "taylor" nor "swift"
- White, when the text is partially matching either "taylor" or "swift"
- Green, when the text is exactly "taylor" or exactly "swift".
You find this in the Basic_iOS project in the Examples folder.
Simon Strandgaard's App Projects
- SwiftyFORM - A framework that makes it easier creating forms for iOS.
- Triangle Draw - A simple yet powerful drawing app for iOS.
- Colorblind Vision - An app that processes live video and presents it as a colorblind person would see it, for iOS.
- Newton Commander - An advanced file manager for Mac.
- GraphToy - A werkkzeug inspired tool for iPad.
- GraphicDesignerToolbox - A werkkzeug inspired tool for Mac.
- AEditor - A programming editor for Mac/Windows/Linux.